Does anyone have an idea to help me extract the lines below that always appear in this pattern?
Palavra1 (é sempre igual)
Linha a ser extraida, de tamanho variavel
Linha a ser extraida, de tamanho variavel
Linha a ser extraida, de tamanho variavel
Palavra2 (é sempre igual)
bla bla bla
bla bla bla
Palavra1 (é sempre igual)
Linha a ser extraida, de tamanho variavel
Linha a ser extraida, de tamanho variavel
Linha a ser extraida, de tamanho variavel
Palavra2 (é sempre igual)
The 3 lines are parts of the same information that I should save in a single variable and display the user, but at the time of file conversion, they ended up being played in 2, 3 or 4 lines.
Here is the code I've come up with:
StringBuilder sb = new StringBuilder();
if(linha.startsWith("palavra1")){
linha = arquivoEntrada.readLine() + 1; //pula a linha
if(!linha.startsWith("palavra2")){ //minha condição de parada
sb.append(linha + " "); //StringBuffer pra ir armazenando as linhas lidas
//como fazer o sistema pular a linha agora??????
} else {
}
variavelQualquer = sb.toString();
}
With this code, I can only get the first line. I tried with while
instead of the second if
, but it did not work.
Any help would be welcome.