The Scanner class provides a convenient method to skip over whitespace and get complete string tokens. However, I am encountering the following situation-
I have input as follows-
Public Type XYZ
A(3) As Byte
B(0) As Byte
C(0) As Byte
End Type
I am using a Scanner to scan through input like this. The scanner correctly returns tokens like “Public”, “Type”, “XYZ”, etc. However, is there a way to find out what was skipped? For instance, after XYZ, the scanner actually skips a “\n” instead of a blankspace – ” “. How to find out what the scanner skipped over?
This isn’t possible as the Scanner class returns the tokens without the trailing delimiter. In this case, without the trailing whitespace character. I don’t believe there is a way to get it back.
One solution would be to parse the file line by line using the BufferedReader and FileReader classes. That way you have full access to the characters individually.