Here you can find the source of getTempDir(String prefix)
public static File getTempDir(String prefix)
//package com.java2s; /******************************************************************************* * Copyright (c) 2011 EclipseSource and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w . ja v a 2s. com * EclipseSource - initial API and implementation ******************************************************************************/ import java.io.File; import java.io.IOException; public class Main { public static File getTempDir(String prefix) { String baseTempDir = System.getProperty("java.io.tmpdir"); File tempDir = new File(baseTempDir, prefix + "-temp"); File result = connonicalize(tempDir); result.deleteOnExit(); return result; } private static File connonicalize(File directory) { File result; try { result = directory.getCanonicalFile(); } catch (IOException ioe) { String msg = "Failed to obtain cannonical path: " + directory.getAbsolutePath(); throw new RuntimeException(msg, ioe); } return result; } }