ByteBufferSeekableByteChannel implements SeekableByteChannel { public long size() throws IOException { return size; } ByteBufferSeekableByteChannel(ByteBuffer buffer); boolean isOpen(); void close(); int read(ByteBuffer dst); int write(ByteBuffer src); long position(); SeekableByteChannel position(long newPosition); long size(); SeekableByteChannel truncate(long size);  }
@Test public void size() throws IOException { SeekableByteChannel channel = new ByteBufferSeekableByteChannel(ByteBuffer.wrap(new byte[]{0x1, 0x2, 0x3, 0x4})); assertEquals(channel.size(), 4); channel.close(); }