Home Java Beginners Find Current Temp Directory



Find Current Temp Directory
Posted on: June 29, 2007 at 12:00 AM
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 
{
  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.

Related Tags for Find Current Temp Directory:
cstringclassobjectdirectorypropertymethodfindgetsystemkeyusingintdefinefinaltoextendexteextendspecurrentinasmnttrtempjclemdirendmeintoobjproctldefinedsystorsrectsoctordirectanykisirproperarstrrtropextssriringrenthstctoendsfinendsjepropprndo


Ask Questions?    Discuss: Find Current Temp Directory  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.