Java examples for File Path IO:Temporary File
Creating a Temporary File
import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { public static void main(String[] argv) { try {// w ww . j a v a 2s .c o m // Create temp file. File temp = File.createTempFile("pattern", ".suffix"); // Delete temp file when program exits. temp.deleteOnExit(); // Write to temp file BufferedWriter out = new BufferedWriter(new FileWriter(temp)); out.write("aString"); out.close(); } catch (IOException e) { } } }