I know this question is already mentioned here:
Start reading the file after a specific word
However, in my case, I want to read a .geojson file from a specific word (including that word) and save that in a String.
{"type": "FeatureCollection","features": [{"type": "Feature","properties": {},"geometry": {"type": "LineString","coordinates": [[4.354282,52.032195],[4.354087,52.032462],[4.353783,52.032962],[4.353579,52.033437],[4.353333,52.034151],[4.352991,52.03545],[4.352517,52.037002],[4.352442,52.037352],[4.352368,52.0378],[4.352336,52.038238],[4.352331,52.039962],[4.352346,52.040706]
]
}
}
]
}
My String should start with {"type": "Linestring" followed by the rest of the file. It has to be applicable for any Linestring geojson.
My code so far:
BufferedReader br = new BufferedReader(new FileReader(
"C:\\Users\\****\\Desktop\\test2.geojson"));
String line;
while ((line = br.readLine()) != null) {
if (line.contains("LineString")) {
break; // breaks the while loop
}
}
while ((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
Can anyone push me in the right direction?
Cheers!