• Register
0 votes

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

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


Further Readings:


9 7 4
38,600 points

Related questions

0 votes
1 answer 336 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 19 views
1 vote
1 answer 15 views
Problem: Hello Kodlogs, I am a new Java programmer. I am practicing Java I/O file handling. I’ve written a Java program to take input a file from my computer. I’ve created a file on my desktop and reading it through my these codes: import java ... the program and it's producing an error Exception in thread "main" java.io.FileNotFoundException: file.txt Any idea to overcome this issue?
asked Jun 17 adamSw 11.3k points
1 vote
1 answer 38 views
Problem: I am a begginer in java programming language and I have been coding for just some days. To practice my programming I wrote this code in java: public class Main { public static void main(String[] argv){ int 2count, h-l, a/b, } } But It shows me the error message ... , . expected Syntax error on token ",", ;expected at Main.main(Main.java:3) Whats is wrong in my code can anyone help me out?
asked Apr 6 LizzyM 6.1k points
1 vote
1 answer 16 views
Problem : I have very recently started to learn programming in Java. I am trying to execute my java code but I am facing the below error. “Exception in thread "main" java.lang.arrayindexoutofboundsexception:” I am unable to understand above error. Please find below my code: ... according to my debugger*/ myodd[j] = input[i]; j++; } return myodd; } Please help me in fixing above error.
asked Mar 30 morrisBson 3.2k points