This section provides you an example that searches the current Temp directory.
Find Current Temp Directory
In this example we are find the current Temp directory.
We are using getProperty(String key) method to find the current temp directory. The getProperty(String key) is defined into System class. System class extends directly Object class. System class is defined final so any class never extends System class. System class allow us to get or set system information. In this example we are pasing "java.io.tmpdir" as key to get the current temp directory into getProperty() method.
The code of the program is given below:
public class TempDirExample
|
The output of the program is given below:
C:\convert\rajesh\completed>javac TempDirExample.java C:\convert\rajesh\completed>java TempDirExample OS current temporary directory is C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ |