public void decompress(String source, String destination) throws IOException {
    GZIPInputStream gzipInputStream = null;

    gzipInputStream = new GZIPInputStream(new FileInputStream(source));

    String outFilename = source + ".txt";
    OutputStream out = new FileOutputStream(outFilename);

    byte[] buf = new byte[1024];

    int len;
    while ((len = gzipInputStream.read(buf)) > 0) {
      out.write(buf, 0, len);
    }

    gzipInputStream.close();
    out.close();
  }
示例#2
0
  public static String unzip(String param) {
    try {
      //			byte[] zipArray = new sun.misc.BASE64Decoder().decodeBuffer(param);
      byte[] zipArray = Base64.decodeBase64(param);

      ByteArrayInputStream bif = new ByteArrayInputStream(zipArray);
      //			InflaterInputStream iis = new InflaterInputStream(bif);
      GZIPInputStream gis = new GZIPInputStream(bif);
      ByteArrayOutputStream unZipbof = new ByteArrayOutputStream();
      int position = 0;
      //			for (int read_byte = 0; (read_byte = iis.read()) != -1; position++) {
      for (int read_byte = 0; (read_byte = gis.read()) != -1; position++) {
        unZipbof.write(read_byte);
      }
      unZipbof.flush();

      byte[] unZipbyteArray = unZipbof.toByteArray();
      String returnUnZipString = new String(unZipbyteArray, "UTF-8");
      return returnUnZipString;
    } catch (Exception ex) {
      return null;
    }
  }
示例#3
0
文件: GZIPIn.java 项目: dirkk/basex
 @Override
 public int read(final byte[] d) throws IOException {
   return zis.read(d);
 }