zip フォルダー内のファイルを一覧表示しようとしています。zip4j ライブラリまたは JavaZipFile
クラスを使用できることを理解しています。
私の質問は、これらのツールのいずれかを使用することです。zip 内の特定のディレクトリにあるファイルを一覧表示するにはどうすればよいですか?
ZipInputStreamだけでタスクを解決することができます。
final String folderNameToBrowse = "folder_name";
final String archivePath = "archive.zip";
final Path pathToBrowse = Paths.get(folderNameToBrowse);
ZipInputStream zis = new ZipInputStream(new FileInputStream(archivePath));
ZipEntry temp = null;
while ( (temp = zis.getNextEntry()) != null) {
if(!temp.isDirectory()){
Path currentPath = Paths.get(temp.getName());
if(pathToBrowse.equals(currentPath.getParent())){
// Here is the file name
System.out.println(currentPath.getFileName());
}
}
}