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
{
public static void main(String[] args)
{
System.out.println("OS current temporary directory is "
+ System.getProperty("java.io.tmpdir"));
}
}
|
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\
|
Download this
example.

|