code: public int read(byte[] buffer, int offset, int size) throws IOException
     {
        long needsToRead = size;
  
        if (needsToRead > (endRange - position + 1))
        {
           needsToRead = endRange - position + 1;
        }
  
        if (needsToRead == 0)
        {
           return -1;
        }
  
        int curReaded = nativeInputStream.read(buffer, offset, (int)needsToRead);
        position += curReaded;
        return curReaded;
     }
docs: {@inheritDoc}