• Register
0 votes
583 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
6 5 3
6,930 points

Please log in or register to answer this question.

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

9 7 4
38,600 points

Related questions

0 votes
1 answer 506 views
506 views
Problem : I am just a beginner in java coding. Recently i got this error and was unable to solve it. Please help me with this. exception in thread "main" java.lang.illegalstateexception: scanner closed
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 4 views
4 views
I've gone through the error reports. Please help.
asked Dec 17, 2020 TeamScript 9.3k points
0 votes
1 answer 4 views
4 views
Thank you in advance for any help?
asked Jan 5 TeamScript 9.3k points
0 votes
1 answer 8 views
8 views
Help me by solving this problem.
asked Jan 2 TeamScript 9.3k points
0 votes
1 answer 11 views
11 views
I know the problem lies with the recursion.
asked Jan 2 TeamScript 9.3k points
0 votes
1 answer 8 views
8 views
Who can help me to solve this problem?
asked Dec 28, 2020 TeamScript 9.3k points
0 votes
1 answer 10 views
0 votes
1 answer 16 views
16 views
Can you please tell me the root cause?
asked Dec 26, 2020 TeamScript 9.3k points
0 votes
1 answer 26 views
26 views
explain with an example?
asked Nov 18, 2020 jagruthi 680 points
0 votes
1 answer 46 views