Java examples for File Path IO:File Permission
Creating Temporary Files with the createTempFile() method
import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; public class Main { public static void main(String[] args) { String tmp_file_prefix = "test_"; String tmp_file_sufix = ".txt"; try {//from ww w . java2 s. co m // passing null prefix/suffix Path tmp_1 = Files.createTempFile(null, null); System.out.println("TMP: " + tmp_1.toString()); // set a prefix and a suffix Path tmp_2 = Files.createTempFile(tmp_file_prefix, tmp_file_sufix); System.out.println("TMP: " + tmp_2.toString()); } catch (IOException e) { System.err.println(e); } } }