jdbc/src/main/java/com/orientechnologies/orient/jdbc/OrientBlob.java
public byte[] getBytes(long pos, int length) throws SQLException {
    if (pos < 1)
      throw new SQLException("The position of the first byte in the BLOB value to be " + "extracted cannot be less than 1");
    if (length < 0)
      throw new SQLException(
          "The number of the consecutive bytes in the BLOB value to " + "be extracted cannot be a negative number");

    int relativeIndex = this.getRelativeIndex(pos);

    ByteBuffer buffer = ByteBuffer.allocate(length);
    int j;
    for (j = 0; j < length; j++) {
      if (relativeIndex == currentChunk.length) {
        // go to the next chunk, if any...
        currentChunkIndex++;
        if (currentChunkIndex < binaryDataChunks.size()) {
          // the next chunk exists so we update the relative index and
          // the current chunk reference
          relativeIndex = 0;
          currentChunk = binaryDataChunks.get(currentChunkIndex);
        } else
          // exit from the loop: there are no more bytes to be read
          break;
      }
      buffer.put(currentChunk[relativeIndex]);
      relativeIndex++;
    }

    return buffer.array();
  }
public byte[] getBytes(long pos, int length) throws SQLException {
    if (pos < 1)
      throw new SQLException("The position of the first byte in the BLOB value to be " + "extracted cannot be less than 1");
    if (length < 0)
      throw new SQLException(
          "The number of the consecutive bytes in the BLOB value to " + "be extracted cannot be a negative number");

    int relativeIndex = this.getRelativeIndex(pos);

    ByteBuffer buffer = ByteBuffer.allocate(length);
    int j;
    for (j = 0; j < length; j++) {
      if (relativeIndex == currentChunk.length) {
        // go to the next chunk, if any...
        currentChunkIndex++;
        if (currentChunkIndex < binaryDataChunks.size()) {
          // the next chunk exists so we update the relative index and
          // the current chunk reference
          relativeIndex = 0;
          currentChunk = binaryDataChunks.get(currentChunkIndex);
        } else
          // exit from the loop: there are no more bytes to be read
          break;
      }
      buffer.put(currentChunk[relativeIndex]);
      relativeIndex++;
    }

    return buffer.array();
  }
/*
(non-Javadoc)

@see java.sql.Blob#getBytes(long, int)