The transition from state 6 to state 7 initializes the buffer
http:// since the first part of a URL has just
Now the transition from state 7 to itself adds characters to the buffer one-by-one until a white space character is found.
Below is a partial implementation of the scanner.
Assume for now that there is a method
which gets the next character from the input file,
and puts it in an
If the end of the file has been reached,
it returns -1.
The program needs to convert this
Look at the red code to see how this is done.
Also, let us continue the assumption that any
character less than space counts as white space.
Check that each transition in the diagram is included
in the code.
When called by another method,
getURL() returns a string
containing the next URL (if there is one)
null if it has scanned past
the end of the file.
A few of the actions are left unfinished. Think about what they should be and click on the button to verify your suspicions.