In the actual project code use process, found that if the Java class Library standard specified Gzipinputstream read compressed data decompression does not work stably, the reason is unknown. Instead of using Inflaterinputstream to replace Gzipinputstream stable, normal work, now the Inflaterinputstream-based Zip\gzip Decompression Code tool method is given:
public static byte[] Decompress (byte[] compress) throws Exception {Bytearrayinputstream Bais = new Bytearrayinputstream (c ompress); Inflaterinputstream IIS = new Inflaterinputstream (Bais); Bytearrayoutputstream BAOs = new Bytearrayoutputstream (), int c = 0;byte[] buf = new Byte[buffer_size];while (true) {c = II S.read (BUF); if (c = = EOF) break;baos.write (buf, 0, c);} Baos.flush (); return Baos.tobytearray ();}
where EOF = -1,buffer_size value can be customized according to its own project.
Android uncompressed Zip/gzip data (based on inflaterinputstream implementation)