Example usage for java.util.zip Deflater getBytesWritten

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

Introduction

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

Prototype

public long getBytesWritten() 

Source Link

Document

Returns the total number of compressed bytes output 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);/*from   w ww. j  av a 2  s .  c o m*/
        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();
    }
}