在java web工程的webroot下建立一个upload文件夹,我利用java程序将文件上传到工程的upload文件夹下,将工程部署到tomcat服务器,那么上传的文件就保存到tomcat中,其高温我怎样利用java程序去删除tomcat中的某个文件。
删和保存差不多啊,只要路径正确,找到文件就能删除
File tempFile = new File("");
if(tempFile.exists())
tempFile.delete();
关键是找路径吧
[code="java"]String path = req.getRealPath("webContent中的路径");
File tempFile = new File(path);
if(tempFile.exists())
tempFile.delete(); [/code]
试试上面几行代码