I'm writing a program in Java and one of the things that I need to do is to create a set of every valid location for a shortest path problem. The locations are defined in a .txt file that follows a strict pattern (one entry per line, no extra whitespace) and is perfect for using .nextLine to get the data. My problem is that 241 lines into the file (out of 432) the scanner stops working 3/4 of the way through an entry and doesn't recognize any new lines.
My code:
//initialize state space
private static Set<String> posible(String posLoc) throws FileNotFoundException {
Scanner s = new Scanner(new File(posLoc));
Set<String> result = new TreeSet<String>();
String availalbe;
while(s.hasNextLine()) {
availalbe = s.nextLine();
result.add(availalbe);
}
s.close();
return result;
}
The Data
Shenlong Gundam
Altron Gundam
Tallgee[scanner stops reading here]se
Tallgeese II
Leo (Ground)
Leo (Space)
Of course, "scanner stops reading here" is not in the data, I'm just marking where scanner stops reading the file. This is 3068 bytes into the file, but that shouldn't affect anything because in the same program, with nearly identical code, I'm reading a 261-line, 14KB .txt file that encodes the paths. Any help would be appreciated.
Thank you.