JAVA ZipFile entries () method does not see directories

I am working on digital documents and digital signatures and I came across a problem.

Input: documentX.adoc - zip file with files and folders inside.

I need to get all the contents in the input file - a list of files and files.

What should I do:

ZipFile adocFile = new ZipFile(documentXFileName);
ArrayList <String> adocFiles = new ArrayList<String>();
Enumeration <? extends ZipEntry> entries;
entries = adocFile.entries();
for (entries = adocFile.entries(); entries.hasMoreElements();)
{
    adocFiles.add(entries.nextElement().getName());
}

I tried to create an ArrayList <ZipEntry> and add ZipEntries instead of names - nothing is the same. Maybe there is another way? It is strange that ZipEntry has a .isDirectory () method ...

Thanks for the help, Martin.

+5
source share
1 answer

In the documentation:

A directory entry is defined as a name whose name ends with the character '/'.

ZIP - . foo/bar.txt foo. Zip , , .

+8

All Articles