public int match(byte[] search,int offset,int length){
  int ret=-1;
  int searchLength=search.length;
  if (searchLength > 0) {
    int limit=Math.min(offset + length,buffer.size()) - searchLength - offset;
    byte byte0=search[0];
    for (int start=offset; start <= limit; ++start) {
      if (buffer.getByte(start) == byte0) {
        int i=0;
        for (; i < searchLength; ++i) {
          if (search[i] != buffer.getByte(start + i)) {
            break;
          }
        }
        if (i == searchLength) {
          ret=start;
          break;
        }
      }
    }
  }
  return ret;
}

public int match ( byte [ ] search , int offset , int length ) { int ret = - 1 ; int searchLength = search . length ; if ( searchLength > 0 ) { int limit = Math . min ( offset + length , buffer . size ( ) ) - searchLength - offset ; byte byte0 = search [ 0 ] ; for ( int start = offset ; start <= limit ; ++ start ) { if ( buffer . getByte ( start ) == byte0 ) { int i = 0 ; for ( ; i < searchLength ; ++ i ) { if ( search [ i ] != buffer . getByte ( start + i ) ) { break ; } } if ( i == searchLength ) { ret = start ; break ; } } } } return ret ; }
locates the bytes within given length from the offset in the buffer .
