int lineNumber = 0;
while ((s = br.readLine()) != null) {
if (++lineNumber < 4)
continue;
// process next line
}
Skip first four lines using BufferedReader
-
02-06-2022 - |
Pregunta
For an App I am developing, I have a text file which I want to read using BufferedReader. The first four lines in the text file or not relevant though, so I do not want to read those. I looked at the documentation on BufferedReader, and I saw that I can use BufferedReader.skip(bytes) where I enter the amount of bytes to skip. However, the first four lines in the text file won't always contain the same amount of information so I think this is not really suitable for my purposes. Do you guys have an idea how to approach this some more practical way?
Solución
Otros consejos
If you don't know how long the lines are the only way to skip 4 lines is reading them and not using the results.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow