I am having a file with rows like this:
Adult literacy rate, population 15+ years, female (%),United Republic of Tanzania,2015,76.08978
Adult literacy rate, population 15+ years, female (%),Zimbabwe,2015,85.28513
Adult literacy rate, population 15+ years, male (%),Honduras,2014,87.39595
Adult literacy rate, population 15+ years, male (%),Honduras,2015,88.32135
If I do this:
try {
Stream<String> file = Files.lines(Paths.get("file.csv"));
file
.filter(r -> r.startsWith("f",43))
.forEach(r -> System.out.println(r));
file.close();
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
}
I get females. Why this does not work?
.map(row -> row.split(","))
.filter(r[2].startsWith("f"))
I can print r[2] like this
.forEach(r -> System.out.println(r[2]));
So that r[2] at least exists.
match()orcontains()?