I work with some big file. I need to check that the file end with a empty line or the previous line end with a LF.
Exemple of file :
a
b
c
d
empty line
To read it I use nio and iterator.
try (Stream<String> ligneFichier = Files.lines(myPath, myCharset)){
Iterator<String> iterator = ligneFichier.iterator();
int i = 0;
while (iterator.hasNext()) {
valeurLigne = iterator.next();
i++;
}
}
When I check the count i I get 4 lines, but there is a 4 + 1 empty (so 5).
Any idea how to heck if the last line end with LF ?
Thanks