【发布时间】:2018-01-25 12:21:49
【问题描述】:
在解压 .7z 文件时,空文件夹会被忽略,我想在解压任何 .7z 文件后也考虑空文件夹。
我的代码如下
SevenZFile sevenZFile = new SevenZFile(new File(filename));
SevenZArchiveEntry entry;
while ((entry = sevenZFile.getNextEntry()) != null){
if (entry.isDirectory()){
continue;
}
File curfile = new File(DestinationPath,entry.getName());
File parent = curfile.getParentFile();
if (!parent.exists()) {
parent.mkdirs();
}
FileOutputStream out = new FileOutputStream(curfile);
byte[] content = new byte[(int) entry.getSize()];
sevenZFile.read(content, 0, content.length);
out.write(content);
out.close();
【问题讨论】:
标签: java extract 7zip compression