JAVA Implementation
In JDK, zlib implementation has been built in the java.util.zip package. For example:CodeAs follows:
1 // Extract
2 Public String decompressdata (string encdata ){
3 try {
4 bytearrayoutputstream Bos = new bytearrayoutputstream ();
5InflateroutputstreamZOS = newInflateroutputstream(BOS );
6 ZOS. Write (convertfrombase64 (encdata ));
7 ZOS. Close ();
8 return new string (Bos. tobytearray ());
9} catch (exception ex ){
10 ex. printstacktrace ();
11 return "unzip_err ";
12}
13}
14
15 // Compression
16 Public String compressdata (string data ){
17 try {
18 bytearrayoutputstream Bos = new bytearrayoutputstream ();
19 deflateroutputstream ZOS = new deflateroutputstream (BOS );
20 ZOS. Write (data. getbytes ());
21 ZOS. Close ();
22 return new string (converttobase64 (Bos. tobytearray ()));
23} catch (exception ex ){
24 ex. printstacktrace ();
25 return "zip_err ";
26}
27}
But in AndroidInflateroutputstream does not seem to support I did not expect how to implement it in Android