Create temporary file in specified directory in Java
Description
The following code shows how to create temporary file in specified directory.
Example
/* w w w . j av a 2 s. co m*/
import java.io.File;
public class Main {
public static void main(String[] args) throws Exception {
File file = null;
File dir = new File("C:/");
file = File.createTempFile("JavaTemp", ".javatemp", dir);
System.out.println(file.getPath());
}
}
The code above generates the following result.