Getting the User’s Temp Directory

Login | Register

Getting the User’s Temp Directory

To get the user’s temporary directory in Java, query for the system property.

The following example shows how to query this System property:

public class Main {
    public static void main(String args[]) {
        String tmpDirProperty = "";
        String tmpDir = System.getProperty(tmpDirProperty);


At Develop In Java, we've been a part of the Java community for over 10 years. If there's anything you'd like us to cover, just ask !

Current versions

  • Java - 1.8
  • Java EE - 7
  • Spring - 4.x