|
Sep
23
|
The File class has two createTempFile() methods for this purpose. One that creates the file in the system temp directory, the other which allows you to specify the directory to create the file in.
// Create a temp file in the system temp directory
File tempFile1 = File.createTempFile(prefix, suffix);
// Create a temp file in the /alternate/temp directory
File tempFile2 = File.createTempFile(prefix, suffix,
new File("/alternate/temp"));



Recent Comments