Create temporary file with specified extension suffix : Temporary File « File « Java Tutorial






import java.io.File;

public class Main {

  public static void main(String[] args) throws Exception {
    File file1 = null;
    File file2 = null;
    file1 = File.createTempFile("JavaTemp", null);
    file2 = File.createTempFile("JavaTemp", ".java");

    System.out.println(file1.getPath());
    System.out.println(file2.getPath());
  }
}








11.5.Temporary File
11.5.1.Create a temporary file
11.5.2.Create temporary file with specified extension suffix
11.5.3.Create temporary file in specified directory