Examples of Inflater


Examples of java.util.zip.Inflater

    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

Examples of java.util.zip.Inflater

    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) {

      Array array = Array.factory(DataType.BYTE.getPrimitiveClassType(), v2.getShape(), uncomp);
View Full Code Here

Examples of java.util.zip.Inflater

    // byte[] comp = new byte[numin - 4];
    // System.arraycopy( b, (int)hoff, comp, 0, numin -4 );

    // decompress the bytes
    Inflater inf = new Inflater(false);

    int resultLength;
    int result = 0;
    //byte[] inflateData = null;
    byte[] tmp;
    int uncompLen = 24500;        /* length of decompress space    */
    byte[] uncomp = new byte[uncompLen];

    inf.setInput(b, (int) hoff, numin - 4);
    int limit = 20000;

    while (inf.getRemaining() > 0) {
      try {
        resultLength = inf.inflate(uncomp, result, 4000);
      }
      catch (DataFormatException ex) {
        System.out.println("ERROR on inflation " + ex.getMessage());
        ex.printStackTrace();
        throw new IOException(ex.getMessage());
      }

      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 = uncompLen + 10000;
        uncomp = new byte[uncompLen];
        System.arraycopy(tmp, 0, uncomp, 0, result);
      }
      if (resultLength == 0) {
        int tt = inf.getRemaining();
        byte[] b2 = new byte[2];
        System.arraycopy(b, (int) hoff + numin - 4 - tt, b2, 0, 2);
        if (headerParser.isZlibHed(b2) == 0) {
          System.arraycopy(b, (int) hoff + numin - 4 - tt, uncomp, result, tt);
          result = result + tt;
          break;
        }
        inf.reset();
        inf.setInput(b, (int) hoff + numin - 4 - tt, tt);
      }

    }
    /*
  while ( inf.getRemaining() > 0) {
   try{
     resultLength = inf.inflate(uncomp);
   }
   catch (DataFormatException ex) {
    System.out.println("ERROR on inflation");
    ex.printStackTrace();
  }
   if(resultLength > 0 ) {
       result = result + resultLength;
       inflateData = new byte[result];
       if(tmp != null) {
          System.arraycopy(tmp, 0, inflateData, 0, tmp.length);
          System.arraycopy(uncomp, 0, inflateData, tmp.length, resultLength);
       } else {
          System.arraycopy(uncomp, 0, inflateData, 0, resultLength);
       }
       tmp = new byte[result];
       System.arraycopy(inflateData, 0, tmp, 0, result);
       uncomp = new byte[(int)uncompLen];
   } else {
       int tt = inf.getRemaining();
       byte [] b2 = new byte[2];
       System.arraycopy(b,(int)hoff+numin-4-tt, b2, 0, 2);
       if( headerParser.isZlibHed( b2 ) == 0 ) {
          result = result + tt;
          inflateData = new byte[result];
          System.arraycopy(tmp, 0, inflateData, 0, tmp.length);
          System.arraycopy(b, (int)hoff+numin-4-tt, inflateData, tmp.length, tt);
          break;
      }
       inf.reset();
       inf.setInput(b, (int)hoff+numin-4-tt, tt);

   }
  }  */
    inf.end();

    int off;
    byte b1, b2;
    b1 = uncomp[0];
    b2 = uncomp[1];
View Full Code Here

Examples of java.util.zip.Inflater

      byte[] content = output.toByteArray();
      input.close();
      output.close();

      ByteArrayInputStream inStream = new ByteArrayInputStream(content);
      InflaterInputStream szlib = new InflaterInputStream(inStream, new Inflater());
      InputSerializer inputSerializer = new InputSerializer(szlib);
      inputSerializer.setProtocolVersion(protocolVersion);

      RPObject object = (RPObject) inputSerializer.readObject(new RPObject());
View Full Code Here

Examples of java.util.zip.Inflater

      byte[] content = output.toByteArray();
      input.close();
      output.close();

      ByteArrayInputStream inStream = new ByteArrayInputStream(content);
      InflaterInputStream szlib = new InflaterInputStream(inStream, new Inflater());
      InputSerializer inputSerializer = new InputSerializer(szlib);

      int protocolVersion = NetConst.FIRST_VERSION_WITH_MULTI_VERSION_SUPPORT - 1;
      Object temp = resultSet.getObject("protocol_version");
      if (temp != null) {
View Full Code Here

Examples of java.util.zip.Inflater

    isCompressed = version < 0;
    if (isCompressed) version = -version;
    if (version != VERSION) throw new BinaryParsingException(
      "Bnux data format version mismatch: " + version + ", must be: " + VERSION);
    if (isCompressed) {
      if (decompressor == null) decompressor = new Inflater();
    }
   
    if (page.get() != DOC_TYPE) // surrogate hack to identify BEGIN_PAGE
      throw new BinaryParsingException("Illegal bnux page header marker");
   
View Full Code Here

Examples of java.util.zip.Inflater

            f = storage.openInputStreamElement(infilename);

            switch (compressionType) {

                case COMPRESSION_ZIP :
                    f = new InflaterInputStream(f, new Inflater());
                    break;

                case COMPRESSION_GZIP :
                    f = new GZIPInputStream(f, b.length);
                    break;
View Full Code Here

Examples of java.util.zip.Inflater

   */
  public static LayerDefinition decode(final InputStream in) throws IOException,
      ClassNotFoundException {
    LayerDefinition layer = new LayerDefinition(0, 0);

    final InflaterInputStream szlib = new InflaterInputStream(in, new Inflater());
    final InputSerializer ser = new InputSerializer(szlib);

    layer = (LayerDefinition) ser.readObject(layer);
    layer.build();
    return layer;
View Full Code Here

Examples of java.util.zip.Inflater

   
    public static final int BASE_SIZE = 100;

    public ZlibInflate(IRubyObject caller) {
        super();
        flater = new Inflater(false);
        collected = new ByteList(BASE_SIZE);
        runtime = caller.getRuntime();
    }
View Full Code Here

Examples of java.util.zip.Inflater

                if (resultLength == outp.length) {
                    outp = new byte[outp.length * 2];
                }
            }
        } catch (DataFormatException e) {
            flater = new Inflater(true);
            flater.setInput(buf.bytes, buf.begin, buf.realSize);
            while (!flater.finished() && resultLength != 0) {
                resultLength = flater.inflate(outp);
                result.append(outp, 0, resultLength);
                if (resultLength == outp.length) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.