public static int getBytesToken ( ParsingContext ctx ) { String input = ctx . getInput ( ) . substring ( ctx . getLocation ( ) ) ; int tokenOffset = 0 ; int i = 0 ; char [ ] inputChars = input . toCharArray ( ) ; for ( ; i < input . length ( ) ; i += 1 ) { char c = inputChars [ i ] ; if ( c == ' ' ) { continue ; } if ( c != BYTES_TOKEN_CHARS [ tokenOffset ] ) { return - 1 ; } else { tokenOffset += 1 ; if ( tokenOffset == BYTES_TOKEN_CHARS . length ) { // Found the token. return i ; } } } return - 1 ; }
handle white spaces .