core/src/main/java/com/orientechnologies/orient/core/record/impl/ORecordBytes.java
public int fromInputStream(final InputStream in) throws IOException {
    final OMemoryStream out = new OMemoryStream();
    try {
      final byte[] buffer = new byte[OMemoryStream.DEF_SIZE];
      int readBytesCount;
      while (true) {
        readBytesCount = in.read(buffer, 0, buffer.length);
        if (readBytesCount == -1) {
          break;
        }
        out.write(buffer, 0, readBytesCount);
      }
      out.flush();
      _source = out.toByteArray();
    } finally {
      out.close();
    }
    _size = _source.length;
    return _size;
  }
public int fromInputStream(final InputStream in) throws IOException {
    final OMemoryStream out = new OMemoryStream();
    try {
      final byte[] buffer = new byte[OMemoryStream.DEF_SIZE];
      int readBytesCount;
      while (true) {
        readBytesCount = in.read(buffer, 0, buffer.length);
        if (readBytesCount == -1) {
          break;
        }
        out.write(buffer, 0, readBytesCount);
      }
      out.flush();
      _source = out.toByteArray();
    } finally {
      out.close();
    }
    _size = _source.length;
    return _size;
  }
Reads the input stream in memory. This is less efficient than {@link #fromInputStream(InputStream, int)} because allocation is
made multiple times. If you already know the input size use {@link #fromInputStream(InputStream, int)}.

@param in
Input Stream, use buffered input stream wrapper to speed up reading
@return Buffer read from the stream. It's also the internal buffer size in bytes
@throws IOException