Pergunta

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?

Foi útil?

Solução

int lineNumber = 0;
while ((s = br.readLine()) != null) {
    if (++lineNumber < 4)
        continue;

    // process next line
}

Outras dicas

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 em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top