我们可以使用zip4j中给出的extractAll方法从zoip filder中提取所有文件,但如果我只需要提取一种文件,比如只提取文本文件或文件名中包含特定子字符串的文件,该怎么办??有没有一种方法可以使用zip4j实现这一点?
我想这个问题可能和我的问题有关。
Read Content from Files which are inside Zip file
但这并不是我想要的。谁能详细解释一下如何使用这个ZipEntry的东西,如果它有助于我的问题得到解决?
发布于 2014-08-20 12:17:54
尝试下面的代码
ZipFile zipFile = new ZipFile("myzip.zip");
// Get the list of file headers from the zip file
List fileHeaderList = zipFile.getFileHeaders();
// Loop through the file headers
for (int i = 0; i < fileHeaderList.size(); i++) {
FileHeader fileHeader = (FileHeader)fileHeaderList.get(i);
String fileName = fileHeader.getFileName();
if(fileName.contains(".java")){
zipFile.extractFile(fileHeader, "c:\\scrap\\");
}
}https://stackoverflow.com/questions/25395933
复制相似问题