Package cs2110
Class WordScanner
java.lang.Object
cs2110.WordScanner
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterator<WordScanner.WordLine>
Iterate over the whitespace-separated words in an input source, returning the (1-based) line
number along with each word. Whitespace and newline definitions follow those of `Scanner`.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordBundles a word with the line number it was found on. -
Constructor Summary
ConstructorsConstructorDescriptionWordScanner(Reader in) Create a WordScanner to iterate over the words in input source `in`. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
WordScanner
Create a WordScanner to iterate over the words in input source `in`.
-
-
Method Details
-
hasNext
public boolean hasNext()- Specified by:
hasNextin interfaceIterator<WordScanner.WordLine>
-
next
- Specified by:
nextin interfaceIterator<WordScanner.WordLine>
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
ioException
Return the last IOException thrown by our source Reader, or null if no IOExceptions have been thrown. Analogous to `Scanner`.
-