How to parse large file like 1.2GB
where total lines in file is 36259190
. How to parse each line to an object and save it in a list.
I get each time an OutOfMemmoryError
.
List<Point> points = new ArrayList<>();
public void m2() throws IOException {
try (BufferedReader reader = Files.newBufferedReader(Paths.get(DATAFILE))) {
reader.lines().map(s -> s.split(","))
.skip(0)
.forEach(p -> points.add(newPoint(p[0], p[1], p[2])));
}
}
class Point {
String X;
String Y;
String Z;
}
Aucun commentaire:
Enregistrer un commentaire