if (count > 0) {
int pos = chars.arrayOffset();
writer.write(chars.array(), pos, count);
}
if (cr.isError() || (all && cr == CoderResult.UNDERFLOW)) {
cr.throwException();
}
if (bytes.remaining() > 0) {
byte[] tmp = new byte[bytes.remaining()];
bytes.get(tmp);
bytes.clear();