如何用java读取zip文件名和zip内文件的文件名,在线等

2024-11-06 09:09:25
推荐回答(1个)
回答(1):

public static void te(File f) throws IOException {
if (!f.exists() || !f.isDirectory()) {
return;
}
File[] subFiles = f.listFiles();
ZipFile zipFile = null;
for (int i = 0, ii = subFiles == null ? 0 : subFiles.length; i < ii; i++) {
if (subFiles[i].isFile()) {
try {
zipFile = new ZipFile(subFiles[i]);
Enumeration entries = zipFile.entries();
System.out.println("压缩文件:" + subFiles[i].getAbsolutePath());
while(entries.hasMoreElements())
{
System.out.println(" entry:" + ((ZipEntry)entries.nextElement()).getName());
}
zipFile.close();
} catch (ZipException e) {
//System.out.println(e.getMessage());
}
}
}
}