ByteBufferSeekableByteChannel implements SeekableByteChannel { public SeekableByteChannel truncate(long size) throws IOException { throw new IOException("Truncate operation doesn't support!"); } 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(expectedExceptions = IOException.class) public void truncate() throws IOException { ByteBuffer original = ByteBuffer.wrap(new byte[]{0x1, 0x2, 0x3, 0x4}); SeekableByteChannel channel = new ByteBufferSeekableByteChannel(original); channel.truncate(0); }