Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Java-get-example Java Get Example

Related Tutorials


 
 

Share on Google+Share on Google+

Java Get Example

Advertisement
In this section of Java Examples, we are going to illustrate various Java Get examples like how to get the date and time, IP Address or memory size etc..

Java Get Example

     

In this section of Java Examples, we are going to illustrate various Java Get examples like how to get the date and time, IP Address or memory size etc.. If you are a Java beginner this is a best place for you to learn different methods, functions and class used in Java Language.

Just go through the given examples to get the things fast and practice these code at your end to learn java easily. After going through this section you will be able to retrieve different values whether it is a database size or memory size using Java programming language.

Java Get Examples..

  1. Get host name in Java: This example is going to show you how to retrieve the host name of a particular IP address. Just go through the example code to see the use of get method in it.
     
  2. Retrieve Month from Date using Java: Learn how to retrieve the month from given particular date. Example code is given for better learning practice
     
  3. IP Address:  This Java Get IP Address example, explains how to retrieve the IP Address of the particular machine.
      
  4. Get Memory Size:  With the help of the given Java code you can easily get the available memory size and can print it on command prompt.
     
  5. Total Memory Usage: While going through the example, you will learn how to obtain the used memory from the total memory using Java program.
      
  6. Use of Get Method in Java: What is method and how to use the get method in Java, this example is going to illustrate you the same thing. Just check the example and run it at your end as well to learn it quickly.
     
  7. Mime Type: It is a technique to describing and attaching files to internet mail. But in this example you will see how to get the Java Mime Types.
      
  8. Get the Month name: If you want to print the name of the month from the current date, this example is exactly for you.. Go through the code it's very simple and easy to understand.
     
  9. Time in Milliseconds: In this code, we have explained how to get the time in milliseconds. Go through the syntax to understand how it works.
     
  10. Get Array Size
    To calculate length of the given array we have used length property. It returns the length of the given array.
      
  11. Absolute value Java
    Absolute value is the only value of a number regardless of a prefixed plus or minus sign. In the example given below we have used abs() method of class java.lang.Math that returns absolute value  of a given number as argument.
     
  12. Date and time code
    In the example given below we will see, how to display current date and time in the user given format. To do all this we have first created instance of the calendar class that returns object of the same class whose time fields have been initialized with the current date and time.
      
  13. Java get ASCII value
    To print ascii value of a character this is the the simplest way to change the type a character. Here in the example given below we will select character from a given string and change their type to integer that will be their ascii value.
        
  14. Class Directory
    In this section of example we are going to describe you how to fetch the class directory's path by the class name. To get the class directory's name and its path we have used two methods getClass() and getResource() over an object instance.
        
  15. Java program to get class name without package
    In this example we are making a simple example which describes you that how you can get the class name without package. 
        
  16. Program to get the color of pixel
    In this java example program we have to write code for getting the pixel color of an image. To get the pixel color we need to first have an image and then we will be able to get the pixel color of any specific or particular pixel in the RGB format.
          
  17. Get column names of a table
    In this example of getting the columns names we need to have connection with the database and then after we will get metadata of this table and find the columns name within the metadata.
      
  18. Java get Blob
    Blob is known as 'binary large object', is a collection of binary data stored as a single entity in a database management system and can hold variable amount of data.
      
  19. Get Byte Array from File 
    In this section, we are going to show the array of bytes from the specified file. For this, a file 'Hello.txt' is passed into the constructor of class File.
       
  20. Calling Class
    In this example we will find the name of the class name.
      
  21. Calling Method
    In this example we will find the name of the method. Provides programmatic access to the stack trace information printed by printStackTrace(). It returns array of StackTraceElement objects.
      
  22. Java get character
    In this example given below, we will learn how to read character from keyboard and display on standard output device.
     
  23. Character from String
    In this example we will see that how to convert string to array of character and retrieve elements from that character array one by one.
     
  24. Classes In Package
    In this section, you will learn how to retrieve all the classes from the package by providing the path of the jar file and the package name.  
      
  25. Get Class Name
    In the example given below we will learn how to get name of the particular class with package name. getName() method returns fully qualified name of the particular class in string format.
      
  26. Java Get Class Location
    In this section, you will learn how to get the class location. For this, we have used the classes URL and ClassLoader. 
      
  27. Show class path
    In this section, you will learn how to get the class path. The method System.getProperties() determines the current system properties. 
      
  28. Get Time Stamp
    In the example you will learn how to display current time. getTime() method returns the number of milliseconds represented by Date object that will be used as argument to create object of java.sql.Time class.
     
  29. Java program to get the Command Line Arguments
    In java we can get the command  line arguments as they are provided on the console. In this example program our program takes arguments from the console and print it on the console.
      
  30. Get computer name in java
    We can get the computer name by the java code program. For getting computer name we have used java.net.InetAddress class.
      
  31. Java Example program to get the current working directory
    This example java program illustrates to get the current working directory (CWD). With the File class object we can get two types of paths in java.
     
  32. Image Size Example
    This Example shows you get the image size. Toolkit class is used to bind the different components to specific native toolkit implementations. 
      
  33. How to get IP Example
    This example shows you ip address of your network interface.
      
  34. Get Image
    This Example shows you get the image.
     
  35. Retrieve IP Address
    This example shows you ip address of your network interface.
     
  36. Print File List in Java
    In this section, you will study how to retrieve all the files and folders from the specified directory. 
     
  37. Code to get Free Space in Java
    In this section, you will study how to obtain available free space in the specified file.
      
  38. How to get File Name
    In this section, you will study how to obtain the name of file. 
     
  39. GMT Time in Java
    In this section, you will study how to obtain the GMT time. GMT stands for Greenwich Mean Time and IST stands for Indian Standard Time. 
      
  40. Java Get Clipboard
    In this section, you will study how to use the method getClipboard().
      
  41. Data type of column field
    In this example java program we have to get the data type of the database table fields.
     
  42. Show current date 
    In this example program we have to get the current date at present now. We have used Calendar class for getting the current date and time instance.
      
  43. Decimal value   
    We can also get the decimal value in the specified format as we wish by calling DecimalFormat class. It will format a long value to the specified string pattern.
      
  44. Default Charset
    We can achieve the default charset through the java program. 
      
  45. Default Locale
    Locale object is a representation of geographical, political, or cultural region. We can get and set our default locale through the java programs.
      
  46. Java program to get the desktop path
    In this example program we have to get the desktop path of the system. In the java environment we can get the desktop path also with the system's property.
     
  47. Java program to get domain name by URL
    We can also get the domain name by the java program. Domain name are used to represent the symbolic representation of numerical internet address. 
     
  48. Java example to get Graphics
    In this section you will learn how to use the method getGraphics().
     
  49. Java example program to get IP address of own system
    An IP (Internet Protocol) address is a numerical unique identification number which is assigned to the devices participating in the network for communication. To get IP address of our own system in a java program we will be using InetAddress class.
     
  50. Java example program to get the operating system's version
    You can check your current system's operating system version by the java code also. For this purpose you have to use the System's property "os.version".
     
  51. Java example program to get the operating system name of the system
    Many times we need to know the current operating system name on which we are working. So in java we have "os.name" property which provides us the information about the current operating system name.
      
  52. Java example program to get Operating System type or architecture
    In java environment we can write java code which will make us enabled to get the operating system type. We can get the operating system architecture or system type by using the system property.
     
  53. Java example program to get the object's ID
    In java there is no any specific method that provides us the object's ID. But each object has its own unique hash value which can be treated as unique Id for that object.

  54. Java example to get Object class name at runtime
    In java there is a way that makes us enabled to get the object class name at runtime. It can be done by calling the getClass() method on the class object. Then  by calling the method getName() we can get the name of the object class.

  55. Java example program to get extension
    To get the file name and file extension separately we can do the string manipulation on the file name. Suppose "filename.ext" is some filename with extension is provided.

  56. Java example to calculate the execution time
    This example program will describe you the way that how one can calculate or get the execution time of a method or program in java. This can be done by subtracting the starting time of the program or method by the ending time of the method.

  57. Java example to get the execution path
    We can get the execution path of the system in java by using the system property. For getting execution path we have used "user.dir" property of the system.

  58. Java example program to get epoch time of windows
    Epoch is used to compare dates with the some other dates or dates with the other time format mathematically. That's why it is being used through out the whole programming world.

  59. Java example program to get the environment variable
    The getenv() method of the java.lang.System provide us the functionality to get the environment variable value. To get the single environment variables value we have to call the getenv("environment variable") method where environment variable is a value that we want to evaluate.

  60. Java get Next Day
    In the given example, we have used the class DateFormatSymbols in order to get the names of the days of the week. The method getWeekdays() provide the string of days of week. To get the current day, we have used the Calendar class.

  61. Java get yesterday's date
    In the given example, we simply get the current date by using the method dateFormat.format(cal.getTime()).But on subtracting one day from the calendar by using the method cal.add(Calendar.DATE, -1), the method dateFormat.format(cal.getTime()) will displayed the yesterday's date.

  62. Java get number of days between dates
    In order to get the number of days between two dates, the given example has set two dates by using the Calendar.set(int year, int month, int date).

  63. Java get Year
    In this section, you will learn how to obtain the current year. The Calendar class provides a getInstance()  method that returns a Calendar object.

  64. Java get year from date
    In this section you will study how to retrieve the year from the date. You can see in the given example that we have called SimpleDateFormat class showing the format of year.

  65. Java get number of Processors
    To display the number of processors available to a current Java Virtual Machine, we have used the method availableProcessors() of class Runtime and the method getRuntime() returns the instance of Runtime class with the java application.

  66. Java get Heap Size
    In this section, we are going to illustrates you how to obtain the heap size. The heap is the area in the memory used for memory storage during the runtime of the program.

  67. Java get Screen Dimensions
    The Toolkit class has a static method called getDefaultToolkit() and can be used to obtain the default Toolkit object for the user's system, which contains information about the user's specific machine.

  68. Java get number of Days in Month
    This example sets the year as 2008, month as Calendar.FEBRUARY and the date as 1 using the method calendar.set(year, month, date) provided by the class Calendar.

  69. Java get number of rows in resultset
    In this section, you will learn how to retrieve the number of rows from the database table. As you know that the data is stored in the database table in the form of row and column.

  70. Java get Http Headers
    In this section, we are going to illustrate you how to get the Http Headers. Here, we are using the URL class which points the resource. In order to make a communication link between the application and a URL, we have used the class URLConnection.

  71. Java get Filename without Extension
    In this section, you will learn how to obtain the filename without extension. For this, the file name or the directory name is being provided.

  72. Java get available Font
    In order to retrieve all the available fonts, we have used the AWT package. The class GraphicsEnvironment describes the collection of all the available GraphicsDevices and Font objects.

  73. Java get Free Memory
    In this section, we are going to obtain the free memory. In order to get the memory left of being allocated, the method getruntime() returns the runtime object associated with the Java application.

  74. Java get Folder Size
    In the given example, we are going to show you the size of specified folder and also the number of files and folders that are presented in the specified folder.

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 15, 2008

Related Tutorials

Discuss: Java Get Example   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com