My Scanner was working fine, reading lines in just dandy and now it is no longer working and continues to throw NoSuchElementException: No Line Found
error.
My code:
try {
File file = new File("Word200D16.txt");
Scanner scanner = new Scanner(file);
while(scanner.hasNextLine()){
for(int i = 0; i < 200; i++){
String line = scanner.nextLine();
elementsToAdd[i] = line;
}
}
} catch(Exception er) {
System.out.println("Error: " + er);
}
Is there anything obviously wrong with this code that I am overlooking? I want each line to be saved into my string array elementsToAdd
.