I am having issues using my delimiter in my scanner. I am currently using a scanner to read a text file and put tokens into a string. My tutor told me to use the delimiter (useDelimiter("\t|\n")). However each token that it is grabbing is ending in /r (due to a return in the text file). This is fine for printing purposes, however i need to get the string length. And instead of returning the number of actual characters, it is returning the number of characters including that /r. Is there a better delimiter I can use that will accomplish the same thing (without grabbing the /r)? code is as follows:
token = studentData.next();
int tokenLength = token.length();
\R pattern matches any linebreak, see documentation.
I guess the remaining
\r char is a partially consumed linebreak in Windows environment. With the aforementioned delimiter, the scanner will properly consume the line.