// creating a temporary file. File temp = File .createTempFile( "temp", ".tmp", new File( "C:\\temp" ) ); // Arrange for this temporary file to be automatically deleted on exit // if we forget to delete it. temp.deleteOnExit();