Example usage for java.nio.charset CoderResult length

List of usage examples for java.nio.charset CoderResult length

Introduction

In this page you can find the example usage for java.nio.charset CoderResult length.

Prototype

int length

To view the source code for java.nio.charset CoderResult length.

Click Source Link

Usage

From source file:co.cask.cdap.logging.gateway.handlers.ChunkedLogReaderCallback.java

private void encodeSend(CharBuffer inBuffer, boolean endOfInput) throws IOException {
    while (true) {
        CoderResult coderResult = charsetEncoder.encode(inBuffer, chunkBuffer, endOfInput);
        if (coderResult.isOverflow()) {
            // if reached buffer capacity then flush chunk
            chunkBuffer.flip();/*w  w  w. j  a  v a2  s .  co  m*/
            chunkResponder.sendChunk(ChannelBuffers.copiedBuffer(chunkBuffer));
            chunkBuffer.clear();
        } else if (coderResult.isError()) {
            // skip characters causing error, and retry
            inBuffer.position(inBuffer.position() + coderResult.length());
        } else {
            // log line was completely written
            break;
        }
    }
}