Android Java压缩Zlib,Gzip,Zip支持J2ME
2010-11-05 00:54:54 来源:WEB开发网System.out.println(content);
byte[] origin = content.getBytes();
System.out.println("原始长度 length is : " + origin.length);
// ZLib 压缩
byte[] zLibCnt = zLib(origin);
System.out.println("zLib压缩后长度 : " + zLibCnt.length);
byte[] unzLibCnt = unZLib(zLibCnt);
System.out.println("zLib解压后长度 : " + unzLibCnt.length);
newContent = new String(unzLibCnt);
System.out.println(newContent);
// GZip 压缩
byte[] gZipCnt = gZip(origin);
System.out.println("GZip压缩后长度 : " + gZipCnt.length);
byte[] ungZipCnt = unGZip(gZipCnt);
System.out.println("GZip解压后长度 : " + ungZipCnt.length);
newContent = new String(ungZipCnt);
System.out.println(newContent);
// Zip 压缩
byte[] zipCnt = zip(origin);
System.out.println("Zip压缩后长度 : " + zipCnt.length);
byte[] unZipCnt = unZip(zipCnt);
System.out.println("Zip解压后长度 : " + unZipCnt.length);
newContent = new String(unZipCnt);
System.out.println(newContent);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
更多精彩
赞助商链接