Package java.util.zip

Examples of java.util.zip.GZIPInputStream


    /*
     * Try with gunziped stream, second
     */
    b.reset(); // Rewind
    if (formatType(Channels.newChannel(new GZIPInputStream(b))) != null) {
      b.close();

      /*
       * Now reopen the same file, but this time without the buffered
       * inputstream in the middle. Try to make things as efficient as possible.
       * TODO: implement much faster channel based GZIP decompression algorithm
       */
      return newInput(t, Channels.newChannel(new GZIPInputStream(
          new FileInputStream(file))), filter);
    }

    throw new IllegalArgumentException(
        "File is not any compressed or decompressed known format ["
View Full Code Here


    /*
     * Try with gunziped stream, second
     */
    b.reset(); // Rewind
    if (formatType(Channels.newChannel(new GZIPInputStream(b))) != null) {
      b.close();

      /*
       * Now reopen the same file, but this time without the buffered
       * inputstream in the middle. Try to make things as efficient as possible.
       * TODO: implement much faster channel based GZIP decompression algorithm
       */
      return newInput(Channels.newChannel(new GZIPInputStream(
          new FileInputStream(file))), filter);
    }

    b.close();
    return factoryForOther.getFactory().newInput(
View Full Code Here

  }
 
  public static long gzipCalculateCRC32(File src) throws IOException {
    final byte[] b = new byte[(int) Size.OneMeg.bytes()];

    final GZIPInputStream in = new GZIPInputStream(new FileInputStream(src), 100);

    final CRC32 crc = new CRC32();
   
    int count = 0;
    int length = 0;
    while ((length = in.read(b)) != -1) {
      System.out.printf("#%d: len=%d\n", count, length);
      crc.update(b, 0, length);
      count ++;
    }

    in.close();
   
    return crc.getValue();

  }
View Full Code Here

         prop = (ClientProperty)obj;
        
         ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
         byte[] ret = null;
         try {
             GZIPInputStream zippedStream = new GZIPInputStream(bais);
             ObjectInputStream objectInputStream = new ObjectInputStream(zippedStream);
             ret = (byte[])objectInputStream.readObject();
             objectInputStream.close();
             // in case we cascade it still works fine
             clientProperties.remove(DbWatcherConstants._COMPRESSION_TYPE);
View Full Code Here

         if (obj instanceof String)
            obj = new ClientProperty(DbWatcherConstants._UNCOMPRESSED_SIZE, null, null, (String)obj);
         prop = (ClientProperty)obj;
        
         try {
            GZIPInputStream ret = new GZIPInputStream(is);
            clientProperties.remove(DbWatcherConstants._COMPRESSION_TYPE);
            clientProperties.remove(DbWatcherConstants._UNCOMPRESSED_SIZE);
            return ret;
         }
         catch (IOException ex) {
View Full Code Here

        }
      }
    }

    if (useGZip) {
      stream = new GZIPInputStream(stream);
    }

    return stream;
  }
View Full Code Here

        InputStream is = new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(body)), 10000);
        return readContents(is, charset, maxKbytes);

      } else if (encoding != null && encoding.equals("gzip")) {
        byte[] body = m.getResponseAsBytes();
        InputStream is = new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(body)), 10000);
        return readContents(is, charset, maxKbytes);

      } else {
        byte[] body = m.getResponseAsBytes(maxKbytes * 1000);
        return new String(body, charset);
View Full Code Here

      if (encoding != null && encoding.equals("deflate")) {
        InputStream is = new BufferedInputStream(new InflaterInputStream(m.getResponseAsStream()), 10000);
        IO.writeToFile(is, file.getPath());

      } else if (encoding != null && encoding.equals("gzip")) {
        InputStream is = new BufferedInputStream(new GZIPInputStream(m.getResponseAsStream()), 10000);
        IO.writeToFile(is, file.getPath());

      } else {
        IO.writeToFile(m.getResponseAsStream(), file.getPath());
      }
View Full Code Here

      if (encoding != null && encoding.equals("deflate")) {
        InputStream is = new BufferedInputStream(new InflaterInputStream(m.getResponseAsStream()), 10000);
        nbytes = IO.appendToFile(is, file.getPath());

      } else if (encoding != null && encoding.equals("gzip")) {
        InputStream is = new BufferedInputStream(new GZIPInputStream(m.getResponseAsStream()), 10000);
        nbytes = IO.appendToFile(is, file.getPath());

      } else {
        nbytes = IO.appendToFile(m.getResponseAsStream(), file.getPath());
      }
View Full Code Here

        }
    }

    private void setupDecompressionInputStream(StreamMessageContext ctx) {
        try {
            ctx.setInputStream(new GZIPInputStream(ctx.getInputStream()));
        } catch (IOException ex) {
            throw new ProtocolException(ex);
        }
    }
View Full Code Here

TOP

Related Classes of java.util.zip.GZIPInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.