/* author by w3cschool.cc main.java */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("临时文件已创建:"); out.close(); }}
以上代码运行输出结果为:
临时文件已创建:
以上就是java 实例 - 创建临时文件的内容。