/** * Parse <code>source</code> for an expected fixed string. * @param source the string to parse * @param expected expected string * @param pos input/ouput parsing parameter. * @return true if the expected string was there */ public static bool parseFixedstring(String source, String expected, ParsePosition pos) { int startIndex = pos.getIndex(); int endIndex = startIndex + expected.length(); if ((startIndex >= source.length()) || (endIndex > source.length()) || (source.substring(startIndex, endIndex).compareTo(expected) != 0)) { // set index back to start, error index should be the start index pos.setIndex(startIndex); pos.setErrorIndex(startIndex); return false; } // the string was here pos.setIndex(endIndex); return true; }