如何在java 6中创建临时文件夹?

Geo*_*Geo 9 java temporary-directory

可能重复:
在Java中创建临时目录

重复:stackoverflow.com/questions/375910

有没有办法在java中创建临时文件夹?我知道File的静态方法createTempFile,但这只会给我一个临时文件.

Joh*_*her 29

我从来没有见过这个好的解决方案,但这就是我做到的.

File temp = File.createTempFile("folder-name","");
temp.delete();
temp.mkdir();
Run Code Online (Sandbox Code Playgroud)


cag*_*boy 8

你有什么理由不能使用java.io.tmpdir属性定义的目录吗?

String dirName = System.getProperty("java.io.tmpdir");
Run Code Online (Sandbox Code Playgroud)


Bri*_*new 5

我会在SO中查看过去的问题以获得解决方案.或者这一个!