Senhores, tenho um programa que lê um arquivo TXT, porem esse arquivo é bem grande, e com o passar o tempo o tamanho do programa que está em execussão fica muito grande, como faço pra isso melhorar?
Ouvi alguma pessoas falando pra dar um flush, como faço isso ?
aqui vai um trecho do Código:
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
Date horario = null;
try {
Path path = Paths.get("C:Caminho");
// Path path = Paths.get("C:/Export/interface.log");
List<String> linhas = Files.readAllLines(path, Charset.forName("ISO8859-1"));
int linhaEncontrada = -1;
long resultado = -1;
linhaEncontrada = buscaAUltimaPalavra(linhas);
String[] textosQuebrados = linhas.get(linhaEncontrada).split(" ");
String dataString = textosQuebrados[0].substring(1);
String horaString = textosQuebrados[1].replaceAll("]", "");
System.out.println("teste " + linhaEncontrada);
try {
horario = sdf.parse(dataString + " " + horaString);
resultado = (new Date().getTime() - horario.getTime()) / 1000;
} catch (ParseException ex) {
//Logger.getLogger(ConsultaLog.class.getName()).log(Level.SEVERE, null, ex);
}
if (resultado == -1) {
// nao faz nada
} else if (resultado > 300) {
LeituraLog.ballcat.setIcon(new ImageIcon(getClass().getResource("/leituralog/img/circle_red.png")));
sendemail teste = new sendemail();
teste.enviarEmail();
} else {
LeituraLog.ballcat.setIcon(new ImageIcon(getClass().getResource("/leituralog/img/circle_green.png")));
}
} catch (IOException ex) {
Logger.getLogger(ConsultaLog.class.getName()).log(Level.SEVERE, null, ex);
}
return horario;