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 record
Bundles 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, wait
Methods 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:
hasNext
in interfaceIterator<WordScanner.WordLine>
-
next
- Specified by:
next
in interfaceIterator<WordScanner.WordLine>
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
ioException
Return the last IOException thrown by our source Reader, or null if no IOExceptions have been thrown. Analogous to `Scanner`.
-