I have a file with thousands of lines, each one representing a point of a line. The number of chars on each line is variable. Im plotting these lines, but i only want to plot every tenth line. I know i could just do something like:
for (int k = 0; k < 9; k++) {
File.getline(buf, 1024);
}
but i was wondering if there was a way to do this without reading in all the lines in between.
it just seems like a waste.
In general, no. Unless your lines are fixed length or otherwise have some hints in them as to where the next lines are, you have no choice but to scan the file for newlines and throw away intervening characters.