Package java.util.zip

Examples of java.util.zip.Inflater


        for(int i=0; i < pool_size; i++) {
            deflater_pool.add(new Deflater(compression_level));
        }
        inflater_pool=new ArrayBlockingQueue<Inflater>(pool_size);
        for(int i=0; i < pool_size; i++) {
            inflater_pool.add(new Inflater());
        }
    }
View Full Code Here


            if(hdr != null) {
                byte[] compressed_payload=msg.getRawBuffer();
                if(compressed_payload != null && compressed_payload.length > 0) {
                    int original_size=hdr.original_size;
                    byte[] uncompressed_payload=new byte[original_size];
                    Inflater inflater=null;
                    try {
                        inflater=inflater_pool.take();
                        inflater.reset();
                        inflater.setInput(compressed_payload, msg.getOffset(), msg.getLength());
                        try {
                            inflater.inflate(uncompressed_payload);
                            if(log.isTraceEnabled())
                                log.trace("uncompressed " + compressed_payload.length + " bytes to " + original_size +
                                        " bytes");
                            // we need to copy: https://jira.jboss.org/jira/browse/JGRP-867
                            Message copy=msg.copy(false);
View Full Code Here

        if (palShades)
            smask = new byte[width * height];
        else if (genBWMask)
            smask = new byte[(width + 7) / 8 * height];
        ByteArrayInputStream bai = new ByteArrayInputStream(idat.getBuf(), 0, idat.size());
        InputStream infStream = new InflaterInputStream(bai, new Inflater());
        dataStream = new DataInputStream(infStream);
       
        if (interlaceMethod != 1) {
            decodePass(0, 0, 1, 1, width, height);
        }
View Full Code Here

        IOUtils.writeString("6", def3);
        def3.close();

        byte[] b = out.toByteArray();
        FastByteArrayInputStream in = new FastByteArrayInputStream(b);
        ContinousInflaterInputStream inf1 = new ContinousInflaterInputStream(in, new Inflater(false), 8192);
        Assert.assertEquals("1", IOUtils.readString(inf1));
        Assert.assertEquals(2, IOUtils.readInt(inf1));
        Assert.assertEquals("3", IOUtils.readString(inf1));
        Assert.assertEquals("4", IOUtils.readString(inf1));
        Assert.assertEquals("5", IOUtils.readString(inf1));
View Full Code Here

        IOUtils.writeString("6", def1);
        def1.close();

        byte[] b = out.toByteArray();
        FastByteArrayInputStream in = new FastByteArrayInputStream(b);
        InflaterInputStream inf1 = new InflaterInputStream(in, new Inflater(false), 8192);
        Assert.assertEquals("1", IOUtils.readString(inf1));
        Assert.assertEquals(2, IOUtils.readInt(inf1));
        Assert.assertEquals("3", IOUtils.readString(inf1));
        Assert.assertEquals("4", IOUtils.readString(inf1));
        Assert.assertEquals("5", IOUtils.readString(inf1));
View Full Code Here

   
  }
 
  public static ByteBuffer decompressData(ByteBuffer inputData) throws DataFormatException {
   
    Inflater decompressor = new Inflater();
   
    decompressor.setInput(inputData.array());
   
    long capacity = 0;
   
    int byte_count = 0;
   
    Vector<ByteBuffer> vector = new Vector<ByteBuffer>();
   
    do {
     
      ByteBuffer tmpData = Misc.getByteBuffer(BLOCK_SIZE);
     
      byte_count = decompressor.inflate(tmpData.array());
   
      tmpData.limit(byte_count);
     
      vector.add(tmpData);
     
      capacity += byte_count;
     
    } while(byte_count !=0 );
   
    decompressor.end();
   
    ByteBuffer outputBuffer = Misc.getByteBuffer(capacity);
   
    for(ByteBuffer buffer : vector) {
     
View Full Code Here

   public void init(Global glob, AddressBase addressBase, PluginInfo pluginConfig)
         throws XmlBlasterException {
      this.addressBase = addressBase;
      this.pluginConfig = pluginConfig;
      this.compressor = new Deflater(Deflater.BEST_COMPRESSION);
      this.decompressor = new Inflater();

      // Add
      //   CbProtocolPlugin[email][1.0]=org.xmlBlaster.protocol.email.CallbackEmailDriver,mail.user=xmlBlaster,mail.password=xmlBlaster,compress/type=zlib:stream
      //   ClientCbServerProtocolPlugin[email][1.0]=org.xmlBlaster.client.protocol.email.EmailCallbackImpl,mail.user=demo,mail.password=demo,mail.pop3.url=pop3://demo:demo@localhost/INBOX,compress/type=zlib:stream
      //   ClientProtocolPlugin[email][1.0]=org.xmlBlaster.client.protocol.email.EmailConnection,mail.user=demo,mail.password=demo,mail.pop3.url=pop3://demo:demo@localhost/INBOX,pop3PollingInterval=1000,compress/type=zlib:stream
View Full Code Here

        super(in);
        buffer = new byte[ZBlockOutputStream.MAXBUFFERSIZE];
        compBuffer = new byte[ZBlockOutputStream.MAXBUFFERSIZE];
        readIndex = 0;
        maxReadIndex = 0;
        inflater = new Inflater();
    }
View Full Code Here

    // Test the next two bytes to see if the image portion looks like
    // it is zlib-compressed
    byte[] b2 = new byte[2];
    b2[0] = b[pos];
    b2[1] = b[pos+1];
    Inflater inflater = new Inflater( false);
    int resultLength = 0;
    int inflatedLen = 0;
    int pos1 = 0;

    if( isZlibHed( b2 ) == 1) {
       Z_type = 1;
       inflater.setInput(b, pos, GINI_HED_LEN );
       try {
            resultLength = inflater.inflate(buf, 0, GINI_HED_LEN);
       }
       catch (DataFormatException ex) {
          log.warn("ERROR on inflation "+ex.getMessage());
          ex.printStackTrace();
          throw new IOException( ex.getMessage());
       }

       if(resultLength != GINI_HED_LEN )System.out.println("Zlib inflated image header size error");
       inflatedLen = GINI_HED_LEN - inflater.getRemaining();

       String inf = new String(buf);
       pos1 = inf.indexOf( "KNES" );
       if ( pos1 == -1 ) pos1 = inf.indexOf ( "CHIZ" );
View Full Code Here

    int result = 0;
    byte[] inflateData = new byte[nx * (ny)];
    byte[] tmp;
    int uncompLen;        /* length of decompress space    */
    byte[] uncomp = new byte[nx * (ny + 1) + 4000];
    Inflater inflater = new Inflater(false);

    inflater.setInput(data, 0, data_size);
    int offset = 0;
    int limit = nx * ny + nx;

    while (inflater.getRemaining() > 0) {
      try {
        resultLength = inflater.inflate(uncomp, offset, 4000);
      }
      catch (DataFormatException ex) {
        System.out.println("ERROR on inflation " + ex.getMessage());
        ex.printStackTrace();
        throw new IOException(ex.getMessage());
      }
      offset = offset + resultLength;
      result = result + resultLength;
      if ((result) > limit) {
        // when uncomp data larger then limit, the uncomp need to increase size
        tmp = new byte[result];
        System.arraycopy(uncomp, 0, tmp, 0, result);
        uncompLen = result + 4000;
        uncomp = new byte[uncompLen];
        System.arraycopy(tmp, 0, uncomp, 0, result);
      }
      if (resultLength == 0) {
        int tt = inflater.getRemaining();
        byte[] b2 = new byte[2];
        System.arraycopy(data, (int) data_size - tt, b2, 0, 2);
        if (isZlibHed(b2) == 0) {
          System.arraycopy(data, (int) data_size - tt, uncomp, result, tt);
          result = result + tt;
          break;
        }
        inflater.reset();
        inflater.setInput(data, (int) data_size - tt, tt);
      }

    }

    inflater.end();

    System.arraycopy(uncomp, 0, inflateData, 0, nx * ny);
    if (data != null) {

      if (levels == null) {
View Full Code Here

TOP

Related Classes of java.util.zip.Inflater

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.