1
我在这里发现了一些用于在Java中创建临时目录的代码。删除临时目录
public static File createTempDirectory() throws IOException
{
final File temp;
temp = File.createTempFile("temp", Long.toString(System.nanoTime()));
if(!(temp.delete()))
{
throw new IOException("Could not delete temp file: " + temp.getAbsolutePath());
}
if(!(temp.mkdir()))
{
throw new IOException("Could not create temp directory: " + temp.getAbsolutePath());
}
return temp;
}
如何在我的servlet的生命结束时处理这个临时目录并删除它?
如何保持对它的静态引用? – Matten 2011-02-18 09:57:25