/** * Skips whitespace characters and then reads one "word" from input. Any additional characters on * the current line of input are retained, and will be read by the next input operation. A word is * defined as a sequence of non-whitespace characters (not just letters!). When using standard IO, * this will not produce an error. In other cases, an IllegalArgumentException will be thrown if * an end-of-file is encountered. */ public String getWord() { skipWhitespace(); StringBuffer str = new StringBuffer(50); char ch = lookChar(); while (ch == EOF || !Character.isWhitespace(ch)) { str.append(readChar()); ch = lookChar(); } return str.toString(); }
private String readIntegerString() { // read chars from input // following syntax of integers skipWhitespace(); if (lookChar() == EOF) return null; if (integerMatcher == null) integerMatcher = integerRegex.matcher(buffer); integerMatcher.region(pos, buffer.length()); if (integerMatcher.lookingAt()) { String str = integerMatcher.group(); pos = integerMatcher.end(); return str; } else return null; }
private String readRealString() { // read chars from input // following syntax of real // numbers skipWhitespace(); if (lookChar() == EOF) return null; if (floatMatcher == null) floatMatcher = floatRegex.matcher(buffer); floatMatcher.region(pos, buffer.length()); if (floatMatcher.lookingAt()) { String str = floatMatcher.group(); pos = floatMatcher.end(); return str; } else return null; }
/** * Skips whitespace characters and then reads one "word" from input. Any additional characters on * the current line of input are retained, and will be read by the next input operation. A word is * defined as a sequence of non-whitespace characters (not just letters!). When using standard IO, * this will not produce an error. In other cases, an IllegalArgumentException will be thrown if * an end-of-file is encountered. */ public String getDoubleQuoteWord() { skipWhitespace(); StringBuffer str = new StringBuffer(50); char ch = lookChar(); int quoteCount = 0; while (ch != EOF && quoteCount < 2) { if (Character.toString(ch).equals("\"")) { quoteCount++; } str.append(readChar()); ch = lookChar(); } return str.toString().replaceAll("\"", ""); }
/** * Skips whitespace characters and then reads a single non-whitespace character from input. Any * additional characters on the current line of input are retained, and will be read by the next * input operation. When using standard IO, this will not produce an error. In other cases, an * IllegalArgumentException will be thrown if an end-of-file is encountered. */ public char getChar() { skipWhitespace(); return readChar(); }