static private boolean matchesStringAtIndex ( char [ ] buf , int index , String str ) { int strLength = str . length ( ) ; if ( index + strLength > buf . length ) { return false ; } for ( int i = 0 ; i < strLength ; ++ i ) { if ( buf [ index + i ] != str . charAt ( i ) ) { return false ; } } return true ; }
Determine if a character buffer contains the specified string a the specified index . Avoids an array index exception if the buffer is too short .