public static String systemTempDir() { String dir = System.getProperty("java.io.tmpdir"); if (isWindows()) { dir = removeTrailingSlash(dir); dir = toForwardSlashes(dir); } return dir; } // Helper functions private static boolean isWindows() { return System.getProperty("os.name").toLowerCase().indexOf("win") >= 0; } private static String removeTrailingSlash(final String s) { return s.replaceFirst("[/\\\\]$", ""); } private static String toForwardSlashes(final String s) { return s.replace("\\", "/"); }If you just want a tmp file use File.createTempFile()
Programming Tips - Java: Get system temporary folder
Date: 2019mar21
Language: Java
Keywords: TEMP, tmp
Q. Java: Get system temporary folder
A. Do System.getProperty("java.io.tmpdir") like this