Example usage for com.fasterxml.jackson.dataformat.smile SmileConstants TOKEN_LITERAL_END_ARRAY

List of usage examples for com.fasterxml.jackson.dataformat.smile SmileConstants TOKEN_LITERAL_END_ARRAY

Introduction

In this page you can find the example usage for com.fasterxml.jackson.dataformat.smile SmileConstants TOKEN_LITERAL_END_ARRAY.

Prototype

byte TOKEN_LITERAL_END_ARRAY

To view the source code for com.fasterxml.jackson.dataformat.smile SmileConstants TOKEN_LITERAL_END_ARRAY.

Click Source Link

Usage

From source file:org.killbill.billing.plugin.meter.timeline.persistent.StreamyBytesPersistentOutputStream.java

private void flushToFile(final File out) throws IOException {
    final byte[] buf = new byte[BUF_SIZE];
    FileOutputStream transfer = null;

    int bytesTransferred = 0;
    try {//  w  w  w . j  a v a  2 s .c  o  m
        transfer = Files.newOutputStreamSupplier(out).getOutput();

        while (true) {
            final int r = inputBuffer.readIfAvailable(buf);
            if (r == 0) {
                break;
            }
            transfer.write(buf, 0, r);
            bytesTransferred += r;
        }
    } finally {
        if (transfer != null) {
            try {
                transfer.write(SmileConstants.TOKEN_LITERAL_END_ARRAY);
                bytesTransferred++;
                bytesOnDisk += bytesTransferred;
            } finally {
                transfer.flush();
            }
        }
    }
    log.debug("Saved {} bytes to disk", bytesTransferred);
}