Expand|Select|Wrap|Line Numbers
- 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.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:817)
at java.util.Scanner.next(Scanner.java:1317)
at tryCountLetter.main(tryCountLetter.java:22)
i dont get it?
why does it say NoSuchElementException?
this is what's inside of the try.txt
Im a newbie -999