Where file is the file MultipartFile
File file2 = File.createTempFile(UUID.randomUUID().toString(), "tmp");
file.transferTo(file2);
file2.deleteOnExit();
The main method of the above meanings:
1、
createTempFile(String prefix, String suffix);
Create an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name. The default save path is: C: \ Documents and Settings \ Administrator \ Local Settings \ Temp.
There overloaded methods:
createTempFile(String prefix, String suffix, File directory);
Create a file in the specified file.
2、
file.transferTo(file2);
The file (MultipartFile) wrote file2 (File).
3、
file2.deleteOnExit();
Delete the file when the JVM exits. You can also callfile.delete();立即删除文件。