String data="aaaaaaaaaaaaaaaaaa";
byte[] b = data.getBytes();
ByteArrayOutputStream out = new ByteArrayOutputStream(); //带缓存的字节输出流
GZIPOutputStream gout = new GZIPOutputStream(out);
gour.write(b);
b = out.toByteArray();
response.setHeader("Content-Encoding", "gzip"); //通知客户端数据的压缩编码
response.setHeader("Content-Length", b.length+"");
response.getOutputStream().wwrite(b);