Skip to content

Instantly share code, notes, and snippets.

@icshih
Last active December 9, 2016 14:12
Show Gist options
  • Save icshih/af5ccabbd4459c4b63248b2e308e5a9f to your computer and use it in GitHub Desktop.
Save icshih/af5ccabbd4459c4b63248b2e308e5a9f to your computer and use it in GitHub Desktop.
Visiting a zip archive
public void visitArchive(String zipFile) {
URI zipUri = URI.create("jar:file:" + zipFile);
try (FileSystem zipfs = FileSystems.newFileSystem(zipUri, new HashMap<>())) {
Files.walkFileTree(zipfs.getPath("/"), new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) throws IOException {
// visiting inside the archive
return FileVisitResult.CONTINUE;
}
});
} catch (IOException e) {
System.out.println("Unable to open the compressed file, " + e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment