Java 创建临时文件1


Java 创建临时文件1

import java.io.*;

public class Main {
   public static void main(String[] args) throws Exception {
      File temp = File.createTempFile ("pattern", ".suffix");
      temp.deleteOnExit();
      BufferedWriter out = new BufferedWriter (new FileWriter(temp));
      out.write("aString");
      System.out.println("temporary file created:");
      out.close();
   }
}