When I try to use java scanner it works and in my list I get all the text file content as a list. But when I try to print within the while loop, it throws java.util.NoSuchElementException: No line found exception at the last line. Why would that be the case, wouldn't mylist also thrown had it been out of bound?
try {
Scanner myscanner = new Scanner(new FileReader(myfilepath));
while(myscanner.hasNextLine()){
//System.out.println(myscanner.nextLine() );
mylist.add(myscanner.nextLine());
numline += 1;
}
myscanner.close();
}
catch (Exception ex) {
ex.printStackTrace();
}