Code example for File

Methods: createNewFile, exists, renameTo

0
    if (tempScnFile.exists() && !tempScnFile.delete())
    { 
      LOG.error("unable to erase temp SCN file: " + tempScnFile.getAbsolutePath());
    } 
 
    File scnFile = new File(_scnFileName);
    if (scnFile.exists() && !scnFile.renameTo(tempScnFile))
    { 
      LOG.error("unable to backup scn file");
    } 
 
    if (!scnFile.createNewFile())
    { 
      LOG.error("unable to create new SCN file:" + scnFile.getAbsolutePath());
    } 
    FileWriter writer = new FileWriter(scnFile);
    writer.write(Long.toString(scn));
    writer.write(SCN_SEPARATOR + new Date().toString());
    writer.flush();
    writer.close();
    LOG.debug("scn persisted: " + scn);