Search This Blog

Showing posts with label temporary folder. Show all posts
Showing posts with label temporary folder. Show all posts

How to Get Path to Temp Directory for Current User in Java

In some cases, you may need to create temporary files. It is preferred to create temporary files and folders in the current user's temporary folder (temp directory) because, the user will be able to clean unwanted files. To get the path to the temp folder of current user, java provides a property key to be used with

System.getProperty()
. it is
"java.io.tmpdir"
.


The following code displays the path to the temporary folder for the current user.
System.out.println("temp directory ="+System.getProperty("java.io.tmpdir"));