/** * Checks whether there's more input to read. * * @exception IOException * If an I/O error occurred in the current Reader */ public boolean moreInput() throws IOException { int inBuf = fillLABuf(1); return (inBuf > 0); }
/** * Get the character at the supplied lookAhead. charAt(0) returns the first * character to be read. * * @return the character at the supplied lookAhead, or -1 if the lookAhead * is after the last character in the stream. */ public int charAt(int lookAhead) throws IOException { // Fill buffer in necessary int inBuf = fillLABuf(lookAhead + 1); // Enough characters in buffer? if (lookAhead >= inBuf) { // Not that much characters in stream anymore return -1; } return laBuf[lookAhead]; }
/** * Check whether the next input is equal to the supplied string * (case-insensitive). * * @param s * The string to compare to the input * @return true if the input is equal to the supplied string, false * otherwise * @exception IOException * If an I/O error occurred in the current Reader or if the * string is longer than the maximum look ahead. */ public boolean nextInputIgnoreCaseIs(String s) throws IOException { // Enough characters in laBuf? int inBuf = fillLABuf(s.length()); if (s.length() > inBuf) { // Not that much characters in stream anymore return false; } // Compare string to characters in LA buffer for (int i = 0; i < s.length(); i++) { if (Character.toUpperCase(laBuf[i]) != Character.toUpperCase(s.charAt(i))) { return false; } } return true; }
/** * Check whether the next input is equal to the supplied string * (case-sensitive). * * @param s * The string to compare to the input * @return true if the input is equal to the supplied string, false * otherwise * @exception IOException * If an I/O error occurred in the current Reader or if the * string is longer than the maximum look ahead. */ public boolean nextInputIs(String s) throws IOException { // Enough characters in laBuf? int inBuf = fillLABuf(s.length()); if (s.length() > inBuf) { // Not that much characters in stream anymore return false; } // Compare string to characters in LA buffer for (int i = 0; i < s.length(); i++) { if (laBuf[i] != s.charAt(i)) { return false; } } return true; }