/** * Constructs a new ByteBufferWrapper of the specified size, backed by a {@link java.nio.ByteBuffer}. * * @param size the new buffer's size, int bytes. * * @return the new buffer. * * @throws ArgumentException if size is negative. */ public BufferWrapper newBuffer(int size) { if (size < 0) { String message = Logging.getMessage("generic.SizeOutOfRange", size); Logging.logger().severe(message); throw new ArgumentException(message); } return(WWBufferUtil.newByteBufferWrapper(size, this.isAllocateDirect())); }
public void read(ByteBuffer byteBuffer, int length) { if (this.tmpBuffer == null || this.tmpBuffer.capacity() < length) { this.tmpBuffer = WWBufferUtil.newCharBuffer(length, true); } this.tmpBuffer.clear(); this.tmpBuffer.limit(length); this.reader.read(byteBuffer, length, this.tmpBuffer); this.buffer.append(this.tmpBuffer); }