0

I have a problem reading the content of a zip file retrieved from a webservice.

The zip file is stored in a byte array called bytes as you can see in the code below.

ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(bytes.get()));
String rawJson = IOUtils.toString(zis);

When I execute IOUtils.toString(zis) I get an OutOfMemoryError: Java heap space.

I'm shure that the problem is caused by the dimension of the json file contained in the zip, is bigger than 150MB. I've tried with other smaller files and I can get the json content without any problem.

Is there a way to read the content of the zip without storing it in memory?

EDIT: I know that I could increase my heap memory but I'm looking for a code-based solution because it woud work on any environment.

Ema.jar
  • 2,370
  • 1
  • 33
  • 43

1 Answers1

0

If u are using IDE, then try to do this

Run Configuration > Arguments > -Xmx7048m

increase the maximum ram to compile

Donald Wu
  • 698
  • 7
  • 20
  • This could be a solution but my code could run on environments I couldn't controll so I'm looking for a more general, and code based, solution. Thank you by the way ;-) – Ema.jar Oct 22 '16 at 17:07