Пример #1
0
 @Override
 public void close() {
   try {
     zis.close();
   } catch (final IOException ex) {
     Util.debug(ex);
   }
 }
  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();
  }
Пример #3
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;
    }
  }
Пример #4
0
 @Override
 public int read(final byte[] d) throws IOException {
   return zis.read(d);
 }