sponsored links

java创建临时文件

 try {
        // 创建临时文件
        File temp = File.createTempFile("pattern", ".suffix");

        //在程序退出时删除临时文件
        temp.deleteOnExit();

        // 向临时文件中写入内容
        BufferedWriter out = new BufferedWriter(new FileWriter(temp));
        out.write("aString");
        out.close();
    } catch (IOException e) {
    }
Tags: