• Register
search
Log In
0 votes
202 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.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

36.1k points
edited by

Related questions

0 votes
1 answer 166 views
166 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
1 vote
1 answer 6 views
6 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 9.5k points
1 vote
1 answer 18 views
18 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 5.7k points
1 vote
1 answer 16 views
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
1 vote
1 answer 22 views
22 views
Problem: I got error while applying weblogic patch useing bsu.sh: patch_download_dir=$FMW_HOME/utils/bsu/cache_dir -patchlist=GFWX -prod_dir=$FMW_HOME/wlserver_10.3 -log=$FMW_HOME/utils/bsu/bsu_weblogic.log Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded ... .bea.plateng.patch.Patch.main(Patch.java:281) Can anyone explain me this and help me to solve this error?
asked Mar 27 LizzyM 5.7k points