Cannot create an empty directory entry with Aspose Java Zip

Hello, I’m using the 25.01 release of Java Zip.

public void addEmptyDirectoryEntry(String entryName) {
        addEntry(entryName, InputStream.nullInputStream());
}

that enters into:

protected void addEntry(String entryName, InputStream content) {
    archive.createEntry(entryName, content);
}

My goal here is to create an empty directory entry, while the result I get is an empty file.
How could I specify it’s a dir?

End entry name with ‘/’.

Thank you, it worked. What if I wanted to use “createEntries” , but with with a certain prefix?

For example I have a folder with structure:

myfolder

  • a.txt
  • b
    • b.txt
    • c
      • c.txt
  • d
  • e
    e.txt
    f.txt

I want to add some other entries, and then as entry “x/y/z/” I want to put “myfolder”. How can I tell to createEntries that I want that name? (x/y/z/)

CreateEntries uses actual paths. You need to use the CreateEntry method with a prefix concatenated to actual file or folder name.
In your case, you need to implement a recursive or queue-based traversal algorithm: visit root (myfolder), visit its leaves (files), then visit branches (subfolders), making each branch the new root for the next level. Let me know you if you need assistance.

I already implemented it and it seems to work well. But I was wondering if there were a shortcut. Thanks!