Here you can find the source of getTempDirectory()
public static File getTempDirectory()
//package com.java2s; //License from project: LGPL import java.io.File; import java.io.IOException; public class Main { private static File tempFile; /**/*from www . j av a 2 s . c o m*/ * returns the Temp Directory of the System * @return temp directory */ public static File getTempDirectory() { if (tempFile != null) return tempFile; String tmpStr = System.getProperty("java.io.tmpdir"); if (tmpStr != null) { tempFile = new File(tmpStr); if (tempFile.exists()) { tempFile = getCanonicalFileEL(tempFile); return tempFile; } } try { File tmp = File.createTempFile("a", "a"); tempFile = tmp.getParentFile(); tempFile = getCanonicalFileEL(tempFile); tmp.delete(); } catch (IOException ioe) { } return tempFile; } /** * Returns the canonical form of this abstract pathname. * @param file file to get canoncial form from it * * @return The canonical pathname string denoting the same file or * directory as this abstract pathname * * @throws SecurityException * If a required system property value cannot be accessed. */ public static File getCanonicalFileEL(File file) { try { return file.getCanonicalFile(); } catch (IOException e) { return file; } } }