• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes
8 views

Problem :

I am getting the run time exception in my program while I am reading a file through a Scanner.
exception in thread "main" java.util.nosuchelementexception: no line found
by (6.9k points)  

1 Answer

0 votes

Solution :

To resolve the issue with Scanner you need to check if there is a next line with hasNextLine()

so the loop becomes

while(sc.hasNextLine()){
    str=sc.nextLine();
    
}

Further Readings:

https://github.com/gradle/gradle/issues/3350

by (21.9k points)  
edited by
...