Example usage for java.util.zip Deflater getBytesRead

List of usage examples for java.util.zip Deflater getBytesRead

Introduction

In this page you can find the example usage for java.util.zip Deflater getBytesRead.

Prototype

public long getBytesRead() 

Source Link

Document

Returns the total number of uncompressed bytes input so far.

Usage

From source file:com.moesol.keys.EncodeUidsTest.java

public void testCompress() {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < 10000; i++) {
        UUID id = UUID.randomUUID();
        sb.append(id);/*www. j  a  va2 s . c om*/
        sb.append(',');
    }
    String result = sb.toString();
    //      System.out.println("val=" + result);

    Deflater deflate = new Deflater();
    try {
        byte[] compressed = new byte[512000];
        deflate.setInput(result.getBytes());
        deflate.finish();
        System.out.printf("in=%d out=%d%n", deflate.getBytesRead(), deflate.getBytesWritten());
        deflate.deflate(compressed);
        System.out.printf("in=%d out=%d%n", deflate.getBytesRead(), deflate.getBytesWritten());
    } finally {
        deflate.end();
    }
}