Try to uncompress with 64k blocks. zlib works on streams, afaik, so there is a chance this will work. But if it doesn't just use sourceFile.readAll() instead of reading 64k at a time. It'll use more memory but will certainly work correctly when uncompressing.