snappy-java icon indicating copy to clipboard operation
snappy-java copied to clipboard

Question: java.lang.NegativeArraySizeException for Large files.

Open AbhishekPowar opened this issue 4 years ago • 0 comments

I had this error while I tried to decompress a large file. Size of sample.snappy is 10 GB. Is there a way around it.

Code source : Source

String fileName = "sample.snappy";
SnappyInputStream sis = new SnappyInputStream(new FileInputStream(fileName));
byte[] buffer = new byte[4096];
int len = 0;
while ((len = sis.read(buffer)) != -1) {
    System.out.println(new String(buffer, 0, len));
}

Error Log:

Exception in thread "main" java.lang.NegativeArraySizeException
        at org.xerial.snappy.SnappyInputStream.readFully(SnappyInputStream.java:116)
        at org.xerial.snappy.SnappyInputStream.readHeader(SnappyInputStream.java:88)
        at org.xerial.snappy.SnappyInputStream.<init>(SnappyInputStream.java:58)

Let me know if this post doesn't belong here

AbhishekPowar avatar Mar 15 '21 09:03 AbhishekPowar