I'm reading lines from a text file ("text.txt") and then storing them into a treemap, until the word apply appears.
However after performing this I don't have the last row "4 apply" I want in the treemap
text.txt
1 add
3 multiply
4 apply
6 add
Scanner input = new Scanner(file);
while(input.hasNextLine()){
String line = input.nextLine();
String[] divline = line.split(" ");
TreeMap<Integer, String> Values = new TreeMap();
if(!divline[1].equals("apply"))
{
Values.put(Integer.valueOf(divline[0]), divline[1]);
}
else
{
Values.put(Integer.valueOf(divline[0]), divline[1]);
break;
}
System.out.println(Values);
}
valores.put(Integer.valueOf(divline[0]), divline[1]);outside deìf