我有这段代码可以读取 zip 文件内容,但我想读取目录内容而不是 zip 文件(必须将 zip 文件视为目录)。我该怎么办 ?
import java.util.HashMap;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class ZipFileDataReader {
private ZipFile zipFile;
private Map zipEntry2dataReader;
public ZipFileDataReader(ZipFile zipFile) {
this.zipFile = zipFile;
zipEntry2dataReader = new HashMap();
}
public synchronized ZipEntryDataReader getZipEntryDataReader(
ZipEntry zipEntry, long offset, int size) {
ZipEntryDataReader entryReader = (ZipEntryDataReader) zipEntry2dataReader
.get(zipEntry.getName());
if (entryReader == null) {
entryReader = new ZipEntryDataReader(zipFile, zipEntry);
zipEntry2dataReader.put(zipEntry.getName(), entryReader);
}
return entryReader;
}
public synchronized void releaseZipEntryDataReader(ZipEntry zipEntry) {
zipEntry2dataReader.remove(zipEntry.getName());
}
}