code: public int read(byte[] b, int off, int len) throws IOException {
          if (position == size) {
              return -1; // EOF
          }
          if (position < buffer.length) {
              int toCopy = (int)Math.min(size - position,
                  Math.min(len, buffer.length - position));
              System.arraycopy(buffer, (int)position, b, off, toCopy);
              if (toCopy > 0) {
                  position += toCopy;
              }
              return toCopy;
          }
          // into disk zone
          int read = diskStream.read(b,off,len);
          if(read>0) {
              position += read;
          }
          return read;
      }
docs: /*
  (non-Javadoc)
  
  @see java.io.InputStream#read(byte[], int, int)