用java的io生成的zip文件删除不掉,同一目录的csv能删除,以至于这个目录不能删除。在生成完文件后,相关的流也close了。
我这里还有个下载这个zip的操作,同样把response.getOutputStream().close(),应该不存在权限的问题。下面是删除的方法:
public void delAllFile(String path) { File file = new File(path); if (!file.exists()) { return; } if (!file.isDirectory()) { return; } String[] tempList = file.list(); File temp = null; for (int i = 0; i < tempList.length; i++) { if (path.endsWith(File.separator)) { temp = new File(path + tempList[i]); } else { temp = new File(path + File.separator + tempList[i]); } if (temp.isFile()) { temp.delete(); } // if (temp.isDirectory()) { // delAllFile(path+"/"+ tempList[i]);//先删除文件夹里面的文件 // delFolder(path+"/"+ tempList[i]);//再删除空文件夹 // } } file.delete(); }