In my code I have
Files.lines(Paths.get(fileName), Charset.forName("Cp1252"))
.filter(k -> k != "")
.forEach(m -> hashmap.put(LocalDateTime.MIN, m));
To read the lines from a file called "info
" (fileName
).
1
2
3
4
5
(blank line)
However, when scanning the HashMap it tells me that only the last line has been inserted using this code:
int x = 0;
for (HashMap.Entry<LocalDateTime, String> s : hashmap.entrySet()) {
x++;
System.out.println(hashmap.size() + ": " + x + ": " + s.getValue());
}
That prints out 1: 1: 5
only once.