I'm a beginner in Java and a geomatics student.
I work with an XTF image, its works like TIFF. This image store about 20000 lines called pings with several informations : coordinates, start time, stop time... The treatments I use on Intellij become too heavy but it works well. I want to cut in two the informations stored in my XTF image : 1 image with the 10000 first pings and the other with the 20000 last pings. Later I would gather the two images. My question is simple : how, with a “for each” loop can I order a limit (<=10000) ? I stored the information in a csv file.
for (XtfPing ping : xtf.getPings())
{
writer.write( Double.toString( ping.x) );
writer.write( "," );
writer.write( Double.toString( ping.y) );
writer.write( "\n" );
}
writer.close();
I know this doesn't fit exactly the OP's situation, but maybe this will help someone else looking to implement an iterate limit using Java 8:
List<Object> myList = ...
List<Object> first10000 = myList.stream().limit(10000).collect(Collectors.toList());
for (Object obj : first10000) {
// do stuff
}
or more simply:
List<Object> myList = ...
myList.stream().limit(1000).forEach(o -> {
// do stuff
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With