Code:
import java.io.*;
import java.util.*;
public class tryCountLetter {
public static void main(String[]args) throws FileNotFoundException{
Scanner inFile = new Scanner(new FileReader("D:\\My Documents\\Java Saves\\try.txt"));
int counter = 0;
String str=inFile.next();
while(str!= "-999")
{
str = inFile.next();
System.out.print(str.length());
}
inFile.close();
}
}
Exception in thread "main" java.util.NoSuc hElementExcepti on
at java.util.Scann er.throwFor(Sca nner.java:817)
at java.util.Scann er.next(Scanner .java:1317)
at tryCountLetter. main(tryCountLe tter.java:22)
i dont get it?
why does it say NoSuchElementEx ception?
this is what's inside of the try.txt
Im a newbie -999
Comment