import java.io.IOException;
import java.util.zip.GZIPOutputStream;
import org.apache.commons.io.output.ByteArrayOutputStream;
//该ByteArrayOutputStream类比jdk的同类好!细看其javadoc:In contrast to the original it doesn't reallocate the whole memory block but allocates additional buffers.
//(压缩都是基于字节码而非字符)
public class TextZip {
public static void main(String[] args) throws IOException {
byte[] bytes = "中文撒大撒大发送大大三大四大赛的温热她跟他中文撒大撒大发送大大大三送大大三大四大赛的温热她跟他中文撒大撒大发送大大大三大四大赛的温热她跟他中文撒大撒大发送大大三大四大赛的温热她跟他"
.getBytes();
//对bytes压缩
ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(1024);
GZIPOutputStream gzipOutput = new GZIPOutputStream(byteOutput, 1024);
gzipOutput.write(bytes);
gzipOutput.close();
//验证一下压缩后的效果对比
System.out.println(bytes.length);
for (byte b : bytes) {