Reputation: 3
I would really like to make a Method with a parameter of type Scanner which checks if the end of a line is reached. I already tried the following but is doesn't work at all. As parameter for in.hasNext()
I already tried \r\n
and \n
as show below.
boolean eoln(Scanner in) {
if (in.hasNext("\n")) {
return true;
}
return false;
}
If it really isn't possible, I'll have to create a method boolean eoln(String src)
with String src = in.nextLine()
. Is there a substitute for nextLine()
which does return the next line as a String, but does not let the Scanner advance past the returned line?
Upvotes: 0
Views: 887