public int findInContent ( String content ) { int n = content . length ( ) ; int m = pattern . length ( ) ; int skip ; char val ; for ( int i = 0 ; i <= n - m ; i = i + skip ) { skip = 0 ; for ( int j = m - 1 ; j >= 0 ; j -- ) { if ( pattern . charAt ( j ) != content . charAt ( i + j ) ) { val = content . charAt ( i + j ) ; skip = ( occurrence . get ( val ) != null ) ? Math . max ( 1 , j - occurrence . get ( val ) ) : j + 1 ; break ; } } if ( skip == 0 ) { return i ; } } return - 1 ; }
Returns the index within this string of the first occurrence of the specified substring . If it is not a substring return - 1 .