@Test public void testGetBackBytesWePutIn() { ByteBuffer[] bufs = wrapArrays(HELLO_WORLD_CHUNKS); BufferChain chain = new BufferChain(bufs); assertTrue(Bytes.equals(Bytes.toBytes("hello world"), chain.getBytes())); }
byte [] getBytes() { if (!hasRemaining()) throw new IllegalAccessError(); byte [] bytes = new byte [this.remaining]; int offset = 0; for (ByteBuffer bb: this.buffers) { System.arraycopy(bb.array(), bb.arrayOffset(), bytes, offset, bb.limit()); offset += bb.capacity(); } return bytes; }
BufferChain { byte [] getBytes() { if (!hasRemaining()) throw new IllegalAccessError(); byte [] bytes = new byte [this.remaining]; int offset = 0; for (ByteBuffer bb: this.buffers) { System.arraycopy(bb.array(), bb.arrayOffset(), bytes, offset, bb.limit()); offset += bb.capacity(); } return bytes; } }
BufferChain { byte [] getBytes() { if (!hasRemaining()) throw new IllegalAccessError(); byte [] bytes = new byte [this.remaining]; int offset = 0; for (ByteBuffer bb: this.buffers) { System.arraycopy(bb.array(), bb.arrayOffset(), bytes, offset, bb.limit()); offset += bb.capacity(); } return bytes; } BufferChain(ByteBuffer ... buffers); }
BufferChain { byte [] getBytes() { if (!hasRemaining()) throw new IllegalAccessError(); byte [] bytes = new byte [this.remaining]; int offset = 0; for (ByteBuffer bb: this.buffers) { System.arraycopy(bb.array(), bb.arrayOffset(), bytes, offset, bb.limit()); offset += bb.capacity(); } return bytes; } BufferChain(ByteBuffer ... buffers);  }
BufferChain { byte [] getBytes() { if (!hasRemaining()) throw new IllegalAccessError(); byte [] bytes = new byte [this.remaining]; int offset = 0; for (ByteBuffer bb: this.buffers) { System.arraycopy(bb.array(), bb.arrayOffset(), bytes, offset, bb.limit()); offset += bb.capacity(); } return bytes; } BufferChain(ByteBuffer ... buffers);   }