code: public static ByteArrayInputStream toStream(ByteBuffer byteBuffer) {
          if (byteBuffer == null) {
              return new ByteArrayInputStream(new byte[0]);
          }
          return new ByteArrayInputStream(copyBytesFrom(byteBuffer));
      }
docs: Wraps a ByteBuffer in an InputStream. If the input {@code byteBuffer}
  is null, returns an empty stream.
  
  @param byteBuffer The ByteBuffer to wrap.
  
  @return An InputStream wrapping the ByteBuffer content.