Package java.util.zip

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


    protected byte[] deflate(String xml) throws UnsupportedEncodingException {
        // Compress the bytes
        byte[] buffer = new byte[1024];
        Deflater compresser = new Deflater(Deflater.DEFAULT_COMPRESSION, true);
        compresser.setInput(xml.getBytes("UTF-8"));
        compresser.finish();
        int compressedDataLength = compresser.deflate(buffer);
        byte[] output = new byte[compressedDataLength];
        for (int i=0; i<compressedDataLength; i++) {
            output[i] = buffer[i];
        }
View Full Code Here


   
    public byte[] deflateToken(byte[] tokenBytes) {
        Deflater compresser = new Deflater();
       
        compresser.setInput(tokenBytes);
        compresser.finish();
       
        byte[] output = new byte[tokenBytes.length];
       
        int compressedDataLength = compresser.deflate(output);
        byte[] result = new byte[compressedDataLength];
View Full Code Here

            // Compress the bytes
            byte[] output = new byte[oledata.length];
            Deflater compresser = new Deflater();
            compresser.setInput(oledata);
            compresser.finish();
            int compressedDataLength = compresser.deflate(output);
            //realloc the data length
            byte[] compressedBytes = new byte[compressedDataLength];
            for (int i = 0; i < compressedDataLength; i++) {
                compressedBytes[i] = output[i];
View Full Code Here

        oos.flush();
        oos.close();

        byte[] ret =  baos.toByteArray();
        compresser.setInput(ret);
        compresser.finish();

        baos.reset();
        byte[] buf = new byte[ret.length/5];

        while (!compresser.finished())
View Full Code Here

  private static byte[] compressBytesInflateDeflate(byte[] inBytes) {
    Deflater deflater = new Deflater(Deflater.BEST_SPEED);
    deflater.setInput(inBytes);
    ByteArrayOutputStream bos = new ByteArrayOutputStream(inBytes.length);
    deflater.finish();
    byte[] buffer = new byte[1024 * 8];
    while (!deflater.finished()) {
      int count = deflater.deflate(buffer);
      bos.write(buffer, 0, count);
    }
View Full Code Here

 
  private static byte[] compressBytesInflateDeflate(byte[] inBytes) {
    Deflater deflater = new Deflater(Deflater.BEST_SPEED);
    deflater.setInput(inBytes);
    ByteArrayOutputStream bos = new ByteArrayOutputStream(inBytes.length);
    deflater.finish();
    byte[] buffer = new byte[1024 * 8];
    while (!deflater.finished()) {
      int count = deflater.deflate(buffer);
      bos.write(buffer, 0, count);
    }
View Full Code Here

    byte outPutInf[] = new byte[50];
    int x = 0;

    Deflater defl = new Deflater();
    defl.setInput(byteArray);
    defl.finish();
    while (!defl.finished()) {
            x += defl.deflate(outPutBuf);
        }
    assertEquals("Deflater at end of stream, should return 0", 0, defl
        .deflate(outPutBuf));
View Full Code Here

    int length = outPutBuf.length - 1;
    int x = 0;

    Deflater defl = new Deflater();
    defl.setInput(byteArray);
    defl.finish();
    while (!defl.finished()) {
            x += defl.deflate(outPutBuf, offSet, length);
        }
    assertEquals("Deflater at end of stream, should return 0", 0, defl.deflate(
        outPutBuf, offSet, length));
View Full Code Here

    byte byteArray[] = { 5, 2, 3, 7, 8 };
    byte outPutBuf[] = new byte[100];

    Deflater defl = new Deflater();
    defl.setInput(byteArray);
    defl.finish();
    while (!defl.finished()) {
            defl.deflate(outPutBuf);
        }
    defl.end();
    helper_end_test(defl, "end");
View Full Code Here

    byte outPutBuf[] = new byte[100];
    byte outPutInf[] = new byte[100];
    int x = 0;
    Deflater defl = new Deflater();
    defl.setInput(byteArray);
    defl.finish();

    // needsInput should never return true after finish() is called
    if (System.getProperty("java.vendor").startsWith("IBM")) {
            assertFalse("needsInput() should return false after finish() is called", defl
                    .needsInput());
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.