Code example for File

Methods: createNewFileexistsrenameTo

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();
Stop searching for code, let great code find you!  Add Codota to your java IDE