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();

```