[英]How to delete the contents of the zip file but not the directory
I am trying to delete the contents of zip file but not the zip directory.I tried FileUtils.cleanDirectory(deteleOldZip)
, but got an error "abc.zip is not a directory". 我试图删除zip文件的内容,但不删除zip目录。我尝试了FileUtils.cleanDirectory(deteleOldZip)
,但收到错误“abc.zip不是目录”。
Is there any other way to do in a single line? 有没有其他方法可以在一行?
Since you just want an empty zip file 因为你只想要一个空的zip文件
String name = file.getAbsolutePath();
FileUtils.deleteDirectory(file)
Then create a new empty zip directory with the file path. 然后使用文件路径创建一个新的空zip目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.