GUJ
Notícias, artigos e o maior fórum brasileiro sobre Java
home
fórum
notícias
tópicos recentes
empregos
artigos
Bem-vindo ao GUJ.
Crie seu login
, ou digite-o para logar no site.
Usuário:
Senha:
Problema para gravar properties
Índice dos Fóruns
»
Java Avançado
Autor
Mensagem
07/03/2008 16:45:44
Assunto:
Problema para gravar properties
Jedi_FeniX
Virtual Machine Man
Membro desde: 26/04/2007 14:32:30
Mensagens: 586
Offline
Depois de um determinado tempo o programa rodando, o arquivo .properties é apagado. Por que?
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()); } } }
O código acima é um código de uma classe que fica em loop infinito.
This message was edited 1 time. Last update was at 07/03/2008 16:47:00
www.bau-de-dev.com
Índice dos Fóruns
»
Java Avançado
Ir para:
Selecione um Fórum
Notícias
Assuntos gerais (Off-topic)
MundoJ - Artigos, Notícias e Debates
Artigos e Tutoriais
Java Básico
Java Avançado
Ferramentas, Frameworks e Utilitários
Desenvolvimento Web
Interface Gráfica
Google Android e Java Micro Edition (ME)
Certificação Java
Persistência: Hibernate, JPA, JDBC e outros
Java Enterprise Edition (Java EE)
Frameworks e Bibliotecas brasileiros
RIA - Flex, JavaFX e outros
Arquitetura de Sistemas
Metodologias de Desenvolvimento e Testes de Software
JavaScript
Ruby & Ruby on Rails
Outras Linguagens
Powered by
JForum 2.1.8
©
JForum Team