Consider using multiple Scanners, one to receive each line, and another to scan each line after you receive it. The only caveat I have to give is that you must close the internal scanner after you finish using it. In fact, you will need to close all scanners after you use them, but especially internal scanners, as they can build and consume resources.
eg.
Scanner fileScanner = new Scanner(myFile); while (fileScanner.hasNextLine()) { String line = fileScanner.nextLine(); Scanner lineScanner = new Scanner(line); while (lineScanner.hasNext()) { String token = lineScanner.next();
Hovercraft full of eels
source share