Package java.util.zip

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


                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();

                    if ( compressed_size < length ) { // JGRP-1000
                        byte[] new_payload=new byte[compressed_size];
View Full Code Here


  public static ByteBuffer compressData(ByteBuffer inputData) {
   
    Deflater compressor = new Deflater();
   
    compressor.setInput(inputData.array());
    compressor.finish();
    long capacity = 0;
   
    int byte_count = 0;
   
    List<ByteBuffer> vector = new Vector<ByteBuffer>();
View Full Code Here

            bytePos = writeBytes(compressedLines, nCompressed, bytePos);
            crc.update(compressedLines, 0, nCompressed);

            crcValue = crc.getValue();
            bytePos = writeInt4((int) crcValue, bytePos);
            scrunch.finish();
            return true;
        }
        catch (IOException e) {
            System.err.println(e.toString());
            return false;
View Full Code Here

            bytePos = writeBytes( compressedLines, nCompressed, bytePos );
            crc.update( compressedLines, 0, nCompressed );

            crcValue = crc.getValue();
            bytePos = writeInt4( (int) crcValue, bytePos );
            scrunch.finish();
            return true;
        }
        catch (IOException e)
        {
            System.err.println( e.toString());
View Full Code Here

        String testString = "Teststring 123";
        byte[] buffer = new byte[100];
        Deflater deflater = new Deflater();

        deflater.setInput(testString.getBytes());
        deflater.finish();
        deflater.deflate(buffer);
        deflater.end();

        assertEquals(testString, Tools.decompressZlib(buffer));
    }
View Full Code Here

  public boolean compress(ByteBuffer in, ByteBuffer out,
                          ByteBuffer overflow) throws IOException {
    Deflater deflater = new Deflater(compressionLevel, true);
    int length = in.remaining();
    deflater.setInput(in.array(), in.arrayOffset() + in.position(), length);
    deflater.finish();
    int outSize = 0;
    int offset = out.arrayOffset() + out.position();
    while (!deflater.finished() && (length > outSize)) {
      int size = deflater.deflate(out.array(), offset, out.remaining());
      out.position(size + out.position());
View Full Code Here

        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);
View Full Code Here

                int tmp_index=getDeflaterIndex();
                Deflater deflater=deflater_pool[tmp_index]; // must be guaranteed to be non-null !
                synchronized(deflater) {
                    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);
View Full Code Here

                            // ByteArrayInputStream(
                            // entityText.getBytes("utf-8"))), -1));
                            byte[] uncompressed = entityText.getBytes("utf-8");
                            Deflater compressor = new Deflater(Deflater.DEFAULT_COMPRESSION, rfc1951);
                            compressor.setInput(uncompressed);
                            compressor.finish();
                            byte[] output = new byte[100];
                            int compressedLength = compressor.deflate(output);
                            byte[] compressed = new byte[compressedLength];
                            System.arraycopy(output, 0, compressed, 0, compressedLength);
                            response.setEntity(new InputStreamEntity(
View Full Code Here

        Deflater compressor = new Deflater();
        compressor.setLevel(Deflater.BEST_COMPRESSION);

        // Give the compressor the data to compress
        compressor.setInput(input);
        compressor.finish();

        // Write the compressed data to the stream
        byte[] buf = new byte[1024];
        while (!compressor.finished())
        {
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.