Create a temporary file : Temporary File « File « Java Tutorial






import java.io.File;

public class Main{
  public static void main(String[] args) throws Exception{
    File f = File.createTempFile("temp_", null);
    
    System.out.println(f.getAbsolutePath());
    
    f.deleteOnExit();
  }
}








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