/** * Flush the output. * * @throws IOException if an I/O error occurs */ private void flushOutput() throws IOException { if (decoderOut.position() > 0) { writer.write(decoderOut.array(), 0, decoderOut.position()); decoderOut.rewind(); } }
private CharBuffer resizeCharBuffer(WebSocket webSocket) throws IOException { int maxSize = charBufferMaxSize; CharBuffer cb = webSocket.cb; if (cb.limit() >= maxSize) { throw new IOException("Message Buffer too small. Use " + StreamingHttpProtocol.class.getName() + " when streaming over websocket."); } long newSize = cb.limit() * 2; if (newSize > maxSize) { newSize = maxSize; } // Cast is safe. newSize < maxSize and maxSize is an int CharBuffer newBuffer = CharBuffer.allocate((int) newSize); cb.rewind(); newBuffer.put(cb); webSocket.cb = newBuffer; return newBuffer; }
cb2.rewind(); if (!TEST_STRING_2.equals(cb2.toString())){ throw new UnsupportedOperationException("UTF-16 requested when runninng on an IBM JDK with broken UTF-16 support. " +
this.cbuf.rewind(); this.bbuf.rewind(); this.bbuf.limit(0); // rewind does not clear the buffer
private String decode() { if (null == decoder) { decoder = UTF8.newDecoder(); } snapshot(); try { if (null == chars || chars.remaining() < buffer.remaining()) { chars = CharBuffer.allocate(buffer.remaining()); } else { chars.rewind(); } decoder.reset(); CoderResult cr = decoder.decode(buffer, chars, true); if (cr.isUnderflow()) { decoder.flush(chars); } chars.flip(); return chars.toString(); } finally { reset(); } }
buf.rewind(); try { ByteBuffer bytes = enc.encode(buf);
private void fillBuffer() throws IOException { int len = (int) Math.min(charBuffer.capacity() - charBuffer.position(), remaining); if (len > 0) { len = reader.read(charBuffer.array(), charBuffer.position(), len); } if (len > 0) { remaining -= len; } else { len = 0; remaining = 0; } length += len; charBuffer.limit(charBuffer.position() + len); charBuffer.rewind(); byteBuffer = ByteBuffer.allocate(Constants.IO_BUFFER_SIZE); boolean end = remaining == 0; encoder.encode(charBuffer, byteBuffer, end); if (end && byteBuffer.position() == 0) { // EOF byteBuffer = null; return; } byteBuffer.flip(); charBuffer.compact(); charBuffer.flip(); charBuffer.position(charBuffer.limit()); }
private void fillBuffer() throws IOException { int len = (int) Math.min(charBuffer.capacity() - charBuffer.position(), remaining); if (len > 0) { len = reader.read(charBuffer.array(), charBuffer.position(), len); } if (len > 0) { remaining -= len; } else { len = 0; remaining = 0; } length += len; charBuffer.limit(charBuffer.position() + len); charBuffer.rewind(); byteBuffer = ByteBuffer.allocate(Constants.IO_BUFFER_SIZE); boolean end = remaining == 0; encoder.encode(charBuffer, byteBuffer, end); if (end && byteBuffer.position() == 0) { // EOF byteBuffer = null; return; } byteBuffer.flip(); charBuffer.compact(); charBuffer.flip(); charBuffer.position(charBuffer.limit()); }
private void _flushBuffer() throws IOException { if (_outputCharBuffer.position() > 0) { _writer.write( _outputCharBuffer.array(), 0, _outputCharBuffer.position()); _outputCharBuffer.rewind(); } }
private void flushOutput() throws IOException { if (decoderOut.position() > 0) { writer.write(decoderOut.array(), 0, decoderOut.position()); decoderOut.rewind(); } } }
/** * Flush the output. * * @throws IOException if an I/O error occurs */ private void flushOutput() throws IOException { if (decoderOut.position() > 0) { writer.write(decoderOut.array(), 0, decoderOut.position()); decoderOut.rewind(); } } }
/** * Flush the output. * * @throws IOException if an I/O error occurs */ private void flushOutput() throws IOException { if (decoderOut.position() > 0) { writer.write(decoderOut.array(), 0, decoderOut.position()); decoderOut.rewind(); } } }
/** * Flush the output. * * @throws IOException if an I/O error occurs */ private void flushOutput() throws IOException { if (decoderOut.position() > 0) { writer.write(decoderOut.array(), 0, decoderOut.position()); decoderOut.rewind(); } } }
/** * Flush the output. * * @throws IOException if an I/O error occurs */ private void flushOutput() throws IOException { if (decoderOut.position() > 0) { writer.write(decoderOut.array(), 0, decoderOut.position()); decoderOut.rewind(); } } }
private void flushOutput() throws IOException { if (decoderOut.position() > 0) { writer.write(decoderOut.array(), 0, decoderOut.position()); decoderOut.rewind(); } } }
/** * Flush the output. * * @throws IOException if an I/O error occurs */ private void flushOutput() throws IOException { if (decoderOut.position() > 0) { out.write(decoderOut.array(), 0, decoderOut.position()); decoderOut.rewind(); } } }
/** * Return the array of characters for this instance. * * @return a char sequence containing the text */ public CharSequence getCharSequence() { if (this.charBuffer == null) { return null; } this.charBuffer.rewind(); return this.charBuffer.asReadOnlyBuffer().subSequence(0, this.charBuffer.limit()); }
/** {@inheritDoc} */ public void endOfNode() throws FOPException { if (charBuffer != null) { charBuffer.rewind(); } super.endOfNode(); getFOEventHandler().characters(this); }