Here you can find the source of getRandomTempFile()
public static File getRandomTempFile() throws IOException
//package com.java2s; //License from project: LGPL import java.io.File; import java.io.IOException; import java.util.UUID; public class Main { private static final String JAVA_IO_TMP_DIR = "java.io.tmpdir"; public static File getRandomTempFile() throws IOException { String tempName = UUID.randomUUID().toString().replaceAll("-", ""); //Create new temp file under OS's temp folder with a random name File tempFile = new File(System.getProperty(JAVA_IO_TMP_DIR) + tempName + ".tmp"); if (!tempFile.createNewFile()) { throw new IOException("Can not create temp file :" + tempFile.getParent()); }/*from w w w . j av a 2 s. c o m*/ return tempFile; } }