@Override protected void initializeAtStartup(final File file) { // rotate on every startup if (file.exists() && rotateAtStartup) { final File backup = new File(file.getParentFile(), file.getName() + OLD_FILE_FORMATTER.format(new Date())); try { rename(file, backup); } catch (IOException e) { throw ControllerLogger.ROOT_LOGGER.couldNotBackUp(e, file.getAbsolutePath(), backup.getAbsolutePath()); } } }
@Override protected void initializeAtStartup(final File file) { // rotate on every startup if (file.exists() && rotateAtStartup) { final File backup = new File(file.getParentFile(), file.getName() + OLD_FILE_FORMATTER.format(new Date())); try { rename(file, backup); } catch (IOException e) { throw ControllerLogger.ROOT_LOGGER.couldNotBackUp(e, file.getAbsolutePath(), backup.getAbsolutePath()); } } }
@Override void initialize() { if (file != null){ return; } File file = new File(pathManager.resolveRelativePathEntry(path, relativeTo)); if (file.exists() && file.isDirectory()) { throw ControllerMessages.MESSAGES.resolvedFileDoesNotExistOrIsDirectory(file); } File parent = file.getParentFile(); if (!parent.exists()) { parent.mkdirs(); } if (file.exists()) { File backup = new File(file.getParentFile(), file.getName() + OLD_FILE_FORMATTER.format(new Date())); try { rename(file, backup); } catch (IOException e) { throw ControllerMessages.MESSAGES.couldNotBackUp(e, file.getAbsolutePath(), backup.getAbsolutePath()); } } try { file.createNewFile(); } catch (IOException e){ throw new RuntimeException(e); } this.file = file; }