1
This code takes my file from log Jboss and displays the first 1000 lines. I wonder how I display the last 1000 lines?
private String log;
public void pesquisar() {
String diretorioCorrente = System.getProperty("jboss.server.log.dir");
File file = new File(diretorioCorrente + File.separator + "server.log");
try {
FileReader reader = new FileReader(file);
BufferedReader input = new BufferedReader(reader);
String linha;
int contador = 0;
StringBuilder sb = new StringBuilder();
while ((linha = input.readLine()) != null) {
sb.append(linha + "\n");
contador++;
if (contador > 1001) {
break;
}
}
input.close();
log = sb.toString();
} catch (IOException ioe) {
System.out.println(ioe);
}
}
Remove this if: if(counter > 1001){break;}. And check if it will read the other lines.
– adelmo00