I\'m stuck with this junit test:
public void test() throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ZipOutputStream zipOu
Recently I had a similar problem while reading a zip bytes created using ZipOutputStream.
The following snippet led to java.lang.NegativeArraySizeException.
zipEntry = zipInputStream.getNextEntry();
byte[] bytes = new byte[(int) zipEntry.getSize()];
An quick solution it was to use Apache commons-io IOUtils to read the all bytes of current entry.
zipEntry = zipInputStream.getNextEntry();
byte[] bytes = org.apache.commons.io.IOUtils.toByteArray(zipInputStream);
I hope this will be helpful to someone.