压缩到字节
//package com.nowjava;// 来 自 N o w J a v a . c o m - 时 代 Java import java.io.*; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; public class Main { public static byte[] compressToBytes(String str) { if (str == null) { return null; } /** n o w j a v a . c o m 提供 **/ byte[] zipBytes = null; ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); ZipOutputStream zipOut = null; try { zipOut = new ZipOutputStream(byteOut); zipOut.putNextEntry(new ZipEntry("zipEntry")); zipOut.write(str.getBytes()); zipOut.closeEntry(); zipBytes = byteOut.toByteArray(); } catch (IOException e) { e.printStackTrace(); } finally { if (zipOut != null) {