private byte[] readFromChannel(ReadableByteChannel readableChannel, int bytesToRead)
      throws IOException {
    ByteBuffer buffer = ByteBuffer.allocate(bytesToRead);
    int bytesRead = 0;
    while (bytesRead < bytesToRead) {
      bytesRead += readableChannel.read(buffer);
    }
    return buffer.array();
  }
Reads {@code bytesToRead} bytes from {@code readableChannel}.
java_src/src/test/java/com/google/crypto/tink/streamingaead/StreamingAeadTest.java