Package java.util.zip

Examples of java.util.zip.Deflater.finish()


        byte[] input = inputString.getBytes("UTF-8");

        // Compress the bytes
        byte[] output = new byte[100];
        def.setInput(input);
        def.finish();
        def.deflate(output);
        inf.setInput(output);
        int compressedDataLength =inf.inflate(input);
        assertEquals(16, inf.getTotalIn());
        assertEquals(compressedDataLength, inf.getTotalOut());
View Full Code Here


        defDict1.setInput(inputString.getBytes());
        defDict2.setInput(inputString.getBytes());

        defDictNo.finish();
        defDict1.finish();
        defDict2.finish();

        int dataLenNo = defDictNo.deflate(outputNo);
        int dataLen1 = defDict1.deflate(output1);
        int dataLen2 = defDict2.deflate(output2);
View Full Code Here

        defDict2.setInput(inputString.getBytes());
        defDict3.setInput(inputString.getBytes());

        defDict1.finish();
        defDict2.finish();
        defDict3.finish();

        int dataLen1 = defDict1.deflate(output1);
        int dataLen2 = defDict2.deflate(output2);
        int dataLen3 = defDict3.deflate(output3);
View Full Code Here

    Deflater deflate = new Deflater(1);
    deflate.setInput(byteArray);
    while (!(deflate.needsInput())) {
      x += deflate.deflate(outPutBuf, x, outPutBuf.length - x);
    }
    deflate.finish();
    while (!(deflate.finished())) {
      x = x + deflate.deflate(outPutBuf, x, outPutBuf.length - x);
    }

    Inflater inflate = new Inflater();
View Full Code Here

    Deflater deflate = new Deflater(1);
    deflate.setInput(byteArray);
    while (!(deflate.needsInput())) {
      x += deflate.deflate(outPutBuf, x, outPutBuf.length - x);
    }
    deflate.finish();
    while (!(deflate.finished())) {
      x = x + deflate.deflate(outPutBuf, x, outPutBuf.length - x);
    }

    Inflater inflate = new Inflater();
View Full Code Here

    Deflater defEmpty = new Deflater(3);
    defEmpty.setInput(emptyArray);
    while (!(defEmpty.needsInput())) {
      x += defEmpty.deflate(outPutBuf, x, outPutBuf.length - x);
    }
    defEmpty.finish();
    while (!(defEmpty.finished())) {
      x += defEmpty.deflate(outPutBuf, x, outPutBuf.length - x);
    }
    assertTrue(
        "the total number of byte from deflate did not equal getTotalOut - inflate(byte)",
View Full Code Here

        byte[] input = inputString.getBytes("UTF-8");

        // Compress the bytes
        byte[] output = new byte[100];
        def.setInput(input);
        def.finish();
        def.deflate(output);
        inf.setInput(output);
        int compressedDataLength =inf.inflate(input);
        assertEquals(16, inf.getTotalIn());
        assertEquals(compressedDataLength, inf.getTotalOut());
View Full Code Here

                Deflater deflater=null;
                try {
                    deflater=deflater_pool.take();
                    deflater.reset();
                    deflater.setInput(payload, msg.getOffset(), length);
                    deflater.finish();
                    deflater.deflate(compressed_payload);
                    compressed_size=deflater.getTotalOut();
                    byte[] new_payload=new byte[compressed_size];
                    System.arraycopy(compressed_payload, 0, new_payload, 0, compressed_size);
                    msg.setBuffer(new_payload);
View Full Code Here

  protected byte[] encrypt(byte[] src) {
    try {
      Deflater compressor = new Deflater(Deflater.BEST_SPEED);
      byte[] compressed = new byte[src.length + 100];
      compressor.setInput(src);
      compressor.finish();
      int totalOut = compressor.deflate(compressed);
      byte[] zipsrc = new byte[totalOut];
      System.arraycopy(compressed, 0, zipsrc, 0, totalOut);
      compressor.end();
      return codec.encode(zipsrc);
View Full Code Here

    static void compress(byte[] input, DataOutput out) throws IOException {
        Deflater deflater = new Deflater();
        deflater.setLevel(Deflater.DEFAULT_COMPRESSION);
        deflater.setStrategy(Deflater.FILTERED);
        deflater.setInput(input);
        deflater.finish();
        byte[] buf = new byte[1024];
        while (!deflater.finished()) {
            int count = deflater.deflate(buf);
            out.write(buf, 0, count);
        }
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.