Depois de um determinado tempo o programa rodando, o arquivo .properties é apagado. Por que?
[code]
Importer.LOGGER.info(“START EXECUTE”);
this.file = new File(Importer.CONTROL_FILE);
Importer.LOGGER.debug(“FILE CONTROL CREATED”);
if(this.file.isFile() && this.file.exists() && this.file.canRead()){
this.properties = new Properties();
try {
this.properties.load(new FileInputStream(this.file));
Importer.LOGGER.debug(“FILE OF CONTROL LOADED FOR PROPERTIES”);
this.fromFile = new RandomAccessFile(new File(Importer.PATH_FILE_READ + this.properties.getProperty(“nameFile”)), “r”);
} catch (FileNotFoundException e) {
Importer.LOGGER.error(“MESSAGE: " + e.getMessage());
Importer.LOGGER.error(“CAUSE: " + e.getCause());
} catch (IOException e) {
Importer.LOGGER.error(“CANNOT OPEN FILE OF CONTROL”);
Importer.LOGGER.error(“MESSAGE: " + e.getMessage());
Importer.LOGGER.error(“CAUSE: " + e.getCause());
}
}else{
Importer.LOGGER.info(“FILE OF CONTROL NOT EXIST OR CANNOT BE READ”);
}
try {
BrazilCalendar brazilCalendar = new BrazilCalendar();
Importer.LOGGER.info(“OPEN FILE OF READ”);
for(;;){
this.fromFile.seek(Long.valueOf(this.properties.getProperty(“pointer”)));
//Insere os dados do arquivo moqueuexxxxx.txt no banco
for(String temp = null; (temp = fromFile.readLine()) != null; ){
Importer.LOGGER.debug(“POINTER: " + this.fromFile.getFilePointer());
this.moQueueDAO.insert(this.transformDataToMoQueue(temp));
Importer.LOGGER.info(“MoQueue INSERTED WITH SUCCESS”);
this.properties.setProperty(“pointer”, String.valueOf(fromFile.getFilePointer()));
this.updateFileConf();
}
//Verifica se o arquivo chegou ao final e verifica se o dia ainda continua o mesmo
if(fromFile.length() == Long.valueOf(this.properties.getProperty(“pointer”)) && Integer.parseInt(this.properties.getProperty(“date”).replace(”-”, “”)) < Integer.parseInt(brazilCalendar.getFullDateForSystem(””))){
String[] arrayDate = this.properties.getProperty(“date”).split(”-");
Importer.LOGGER.debug(“ARRAY DATE 2:” + arrayDate[2]);
brazilCalendar.set(BrazilCalendar.DAY_OF_MONTH, Integer.parseInt(arrayDate[2]));
Importer.LOGGER.debug(“ARRAY DATE 1: " + arrayDate[1]);
brazilCalendar.set(BrazilCalendar.MONTH, (Integer.parseInt(arrayDate[1]) - 1));
Importer.LOGGER.debug(“ARRAY DATE 0: " + arrayDate[0]);
brazilCalendar.set(BrazilCalendar.YEAR, Integer.parseInt(arrayDate[0]));
Importer.LOGGER.debug(“FULL DATE: " + brazilCalendar.getFullDateForSystem(”-”));
this.properties.setProperty(“pointer”, “0”);
this.properties.setProperty(“nameFile”, Importer.PREFIX_FILE_READ + brazilCalendar.nextFullDateForSystem(”") + “.txt”);
this.properties.setProperty(“date”, brazilCalendar.getFullDateForSystem("-"));
this.updateFileConf();
fromFile.close();
fromFile = new RandomAccessFile(new File(Importer.PATH_FILE_READ + this.properties.getProperty(“nameFile”)), “r”);
Importer.LOGGER.info(“UPDATE FILE CONTROL”);
}
}
/*
fromFile.close();*/
} catch (FileNotFoundException e1) {
Importer.LOGGER.error("FILE OF READ NOT FOUND");
Importer.LOGGER.error("MESSAGE: " + e1.getMessage());
Importer.LOGGER.error("CAUSE: " + e1.getCause());
} catch (IOException e1) {
Importer.LOGGER.error("FILE OF READ CANNOT READ OR CANNOT OPEN");
Importer.LOGGER.error("MESSAGE: " + e1.getMessage());
Importer.LOGGER.error("CAUSE: " + e1.getCause());
} catch (SQLException e) {
Importer.LOGGER.error("CANNOT INSERT MoQueue");
Importer.LOGGER.error("MESSAGE: " + e.getMessage());
Importer.LOGGER.error("CAUSE: " + e.getCause());
/*try {
Thread.sleep(1000);
} catch (InterruptedException e2) {
Importer.LOGGER.error("MESSAGE: " + e2.getMessage());
Importer.LOGGER.error("CAUSE: " + e2.getCause());
}*/
} finally{
try {
Importer.LOGGER.debug("FINALLY START");
Importer.LOGGER.debug("pointer" + String.valueOf(this.fromFile.getFilePointer()));
Importer.LOGGER.debug("nameFile" + this.properties.getProperty("nameFile"));
Importer.LOGGER.debug("date" + this.properties.getProperty("date"));
this.properties.setProperty("pointer", String.valueOf(this.fromFile.getFilePointer()));
this.properties.setProperty("nameFile", this.properties.getProperty("nameFile"));
this.properties.setProperty("date", this.properties.getProperty("date"));
this.updateFileConf();
this.fromFile.close();
this.execute();
} catch (IOException e1) {
Importer.LOGGER.error("MESSAGE: " + e1.getMessage());
Importer.LOGGER.error("CAUSE: " + e1.getCause());
}
}
}[/code]
O código acima é um código de uma classe que fica em loop infinito.