Reputation: 87
I'm making an app for android and a need to check if the user's zip file entry is in the right format before unzip it, to avoid waste of time unziping. Could anyone help me?
PS.: I just need to know the name of the files inside the zip
Upvotes: 1
Views: 256
Reputation: 8481
Use ZipFile: it uses random access to jump between file positions in the zip archive:
try (ZipFile file = new ZipFile("file.zip")) {
final Enumeration<? extends ZipEntry> entries = file.entries();
while (entries.hasMoreElements()) {
final ZipEntry entry = entries.nextElement();
System.out.println(entry.getName());
}
}
Upvotes: 1