This code takes my JBoss log file and displays the first 1000 lines. I would like to know how I can 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);
}
}