This snippet prints 2 and 0 ByteArrayInputStream input = new ByteArrayInputStream(new byte[] {1, 2}); ReadableByteChannel channel = Channels.newChannel(input); ByteBuffer buffer = ByteBuffer.allocate(2); System.out.println(channel.read(buffer)); System.out.println(channel.read(buffer)); but should prints 2 and -1 because we reach the end of the stream. Rémi