0

I have a zip file structure.

MyZip.zip
    folder_1
        folder_1_1
            file_1_1_1
            file_1_1_2
        folder_1_2
            file_1_2_1
            file_1_2_2
    folder_2
        folder_2_1
            folder_2_1_1
                needed_file   //This is the file I need to read.

So, I need to read file - needed_file from folder_2_1_1 folder, which is inside of folder_2_1, and so on.

This is how to unzip all data from a zip file. I do not need to unzip the archive. My question, is it possible to retrieve the file I need without unzipping the whole archive.

I tried

ZipFile zipFile = new ZipFile(file);
ZipEntry entry = zipFile.getEntry("folder_2");

But I did not find a way how to manipulate zipEntry as a directory.

Yan Khonski
  • 12,225
  • 15
  • 76
  • 114
  • 1
    Try with `path/to/your/filename` as entry. – Pshemo Sep 17 '18 at 09:44
  • This may interest you http://tutorials.jenkov.com/java-zip/zipfile.html – Pshemo Sep 17 '18 at 09:47
  • Found my answer here https://stackoverflow.com/a/32179328/4587961. `while (entries.hasNext()) { ZipEntry ze = entries.next(); if (zp.getName().equals(name_with_folder)) {readData(zp);} }` – Yan Khonski Sep 17 '18 at 10:03

0 Answers0