Package java.util.zip

Examples of java.util.zip.InflaterInputStream


            LOGGER.info("URL connection input stream is compressed using gzip");
            is = new BufferedInputStream(new GZIPInputStream(
                    conn.getInputStream()));
        } else if ("deflate".equals(contentEncoding)) {
            LOGGER.info("URL connection input stream is compressed using deflate");
            is = OWLOntologyDocumentSourceBase.wrap(new InflaterInputStream(
                    conn.getInputStream(), new Inflater(true)));
        } else {
            is = OWLOntologyDocumentSourceBase.wrap(conn.getInputStream());
        }
        return is;
View Full Code Here


   
    try
   
     
      if(useCompress)
        breader = new BufferedReader(new InputStreamReader(new InflaterInputStream(new FileInputStream(file)), "GBK"));
      else
        breader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "GBK"));
     
      String line;
      boolean isFirstLine = true;
View Full Code Here

    public TryInflaterInputStream(InputStream in) throws IOException {
        BufferedInputStream bufferedIn = new BufferedInputStream(in, TEST_COMPRESSED_SIZE);
        bufferedIn.mark(TEST_COMPRESSED_SIZE);
        try {
            InflaterInputStream testCompressedIn = new InflaterInputStream(bufferedIn);
            byte[] temp = new byte[TEST_COMPRESSED_SIZE / 10];
            testCompressedIn.read(temp);

            this.in = new InflaterInputStream(bufferedIn);
        } catch (Exception ex) {
            this.in = bufferedIn;
        } finally {
            bufferedIn.reset();
        }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public byte[] inflate(ByteArrayOutputStream imageBytes) throws IOException {
        InflaterInputStream inflater = new InflaterInputStream(new ByteArrayInputStream(imageBytes.toByteArray()));
        ByteArrayOutputStream inflatedOut = new ByteArrayOutputStream();

        int readLength;
        byte[] block = new byte[8192];
        while ((readLength = inflater.read(block)) != -1) {
            inflatedOut.write(block, 0, readLength);
        }

        return inflatedOut.toByteArray();
    }
View Full Code Here

    public static byte[] processDeflateEncoded(byte[] compressed, int sizeLimit) throws IOException {
        ByteArrayOutputStream outStream = new ByteArrayOutputStream(EXPECTED_DEFLATE_COMPRESSION_RATIO * compressed.length);

        // "true" because HTTP does not provide zlib headers
        Inflater inflater = new Inflater(true);
        InflaterInputStream inStream = new InflaterInputStream(new ByteArrayInputStream(compressed), inflater);

        byte[] buf = new byte[BUF_SIZE];
        int written = 0;
        while (true) {
            try {
                int size = inStream.read(buf);
                if (size <= 0) {
                    break;
                }
               
                if ((written + size) > sizeLimit) {
View Full Code Here

            case ZipEntry.STORED:
                return bis;
            case ZipEntry.DEFLATED:
                bis.addDummy();
                final Inflater inflater = new Inflater(true);
                return new InflaterInputStream(bis, inflater) {
                    @Override
                    public void close() throws IOException {
                        super.close();
                        inflater.end();
                    }
View Full Code Here

            case ZipEntry.STORED:
                return bis;
            case ZipEntry.DEFLATED:
                bis.addDummy();
                final Inflater inflater = new Inflater(true);
                return new InflaterInputStream(bis, inflater) {
                    @Override
                    public void close() throws IOException {
                        super.close();
                        inflater.end();
                    }
View Full Code Here

    return new DeflaterInputStream(in);
  }

  @Override
  public InputStream uncompress(InputStream in) {
    return new InflaterInputStream(in);
  }
View Full Code Here

            //log.debug( "wrapping response in GZIPInputStream" );
            respBody = new GZIPInputStream( respBody );
          }
          else if( contentEncoding.contains( "deflate" ) ) {
            //log.debug( "wrapping response in InflaterInputStream" );
            respBody = new InflaterInputStream(respBody);
          }
        }
        else {
          Header contentTypeHeader = method.getResponseHeader( "Content-Type" );
          if( contentTypeHeader != null ) {
            String contentType = contentTypeHeader.getValue();
            if( contentType != null ) {
              if( contentType.startsWith( "application/x-gzip-compressed" ) ) {
                //log.debug( "wrapping response in GZIPInputStream" );
                respBody = new GZIPInputStream( respBody );
              }
              else if ( contentType.startsWith("application/x-deflate") ) {
                //log.debug( "wrapping response in InflaterInputStream" );
                respBody = new InflaterInputStream(respBody);
              }
            }
          }
        }
      }
View Full Code Here

        @Override
        public void run() {
          try {
            if(br.receive()) {
              ByteArrayInputStream bais = new ByteArrayInputStream(data);
              InflaterInputStream dis = new InflaterInputStream(bais);
              SimpleFieldSet fs;
              try {
                fs = new SimpleFieldSet(new BufferedReader(new InputStreamReader(dis, "UTF-8")), false, false);
              } catch (UnsupportedEncodingException e) {
                synchronized(DarknetPeerNode.this) {
View Full Code Here

TOP

Related Classes of java.util.zip.InflaterInputStream

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.