Getting The User's Temp Directory

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

The following example shows how to query this System property:

public class Main {
    public static void main(String args[]) {
        String tmpDirProperty = "java.io.tmpdir";

        String tmpDir = System.getProperty(tmpDirProperty);

        System.out.println(tmpDir);
    }
}

Add a comment