The java.io package provides input and output functionality to the Java program. The package includes classes for input and output through the console, files, streams, and bytes.
One of the classes from the java.io package that is frequently used is System.getProperty. This method returns the system's properties as a string value. It takes a string argument representing the name of the property that needs to be retrieved.
Example 1: The following code retrieves the user directory property and prints it on the console.
In this example, the property "user.dir" is used to retrieve the user directory of the system. The returned value is assigned to a string variable userDirectory, and then printed on the console.
Example 2: The following code retrieves the Java version property and prints it on the console.
In this example, the property "java.version" is used to retrieve the current version of the Java on the system. The returned value is assigned to a string variable javaVersion, and then printed on the console.
The System.getProperty method belongs to the java.lang.System class, which is part of the Java Standard Library. Hence, it does not require any additional package libraries.
Java System.getProperty - 30 examples found. These are the top rated real world Java examples of java.io.System.getProperty extracted from open source projects. You can rate examples to help us improve the quality of examples.