apache - How to add custom information into Zip archive for every ZipArchiveEntry in Java (getComment is always null) -
using: java, apache commons compress (1.10) (org.apache.commons.compress.archivers.zip.ziparchiveoutputstream
) (org.apache.commons.compress.archivers.zip.ziparchiveentry
)
is there way, how add custom information (byte[] or string) zip archive entry?
i tried use following methods:
entry.setextra(byte[] extra); entry.setextrafields(zipextrafield[] fields); entry.setcomment(string comment);
but seems setextra
limited 2 bytes , setextrafields
takes zip standarized fields, not custom parameter.
the promissing setcomment
null (decompression), no matter if , set (compression).
compression example (using setcomment
):
ziparchiveoutputstream zaos = new ziparchiveoutputstream(fos); ziparchiveentry entry = new ziparchiveentry(file.getname()); entry.setcomment("test"); zaos.putarchiveentry(entry); // write data zaos.closearchiveentry(); zaos.finish();
on decompression entry.getcomment()
null.
Comments
Post a Comment