/** * Save configuration settings to a file. * * @param contents * the configuration settings * @param file * the file to write to * @throws IOException * if the settings could not be saved because of an I/O problem */ public static void saveConfigurationContents(String contents, File file) throws IOException { if (file.getParentFile().mkdirs() || file.getParentFile().canWrite()) { IOUtil.writeString(contents, file); } }
/** * Save configuration settings to a file. * * @param contents * the configuration settings * @param file * the file to write to * @throws IOException * if the settings could not be saved because of an I/O problem */ public static void saveConfigurationContents(String contents, File file) throws IOException { if (file.getParentFile().mkdirs() || file.getParentFile().canWrite()) { IOUtil.writeString(contents, file); } }
private File getConfigFile() throws IOException { File f = new File(getConfDir(), LOGBACK_CONFIG_FILE); if (!f.exists() || !f.canRead()) { String content = ConfigurationUtil.loadConfigurationContents(LOGBACK_CONFIG_FILE); content = content.replace("${logging.main.file}", LOG_FILE); content = content.replace("${logging.event.user.file}", USER_EVENT_LOG_FILE); content = content.replace("${logging.event.admin.file}", ADMIN_EVENT_LOG_FILE); content = content.replace("${logging.event.user.logger}", USER_EVENT_LOGGER_NAME); content = content.replace("${logging.event.admin.logger}", ADMIN_EVENT_LOGGER_NAME); if (!f.getParentFile().mkdirs() && !f.getParentFile().canWrite()) { throw new IOException("Not allowed to write logging configuration file to " + f.getParent()); } else { IOUtil.writeString(content, f); } } return f; }
private File getConfigFile() throws IOException { File f = new File(getConfDir(), LOGBACK_CONFIG_FILE); if (!f.exists() || !f.canRead()) { String content = ConfigurationUtil.loadConfigurationContents(LOGBACK_CONFIG_FILE); content = content.replace("${logging.main.file}", LOG_FILE); content = content.replace("${logging.event.user.file}", USER_EVENT_LOG_FILE); content = content.replace("${logging.event.admin.file}", ADMIN_EVENT_LOG_FILE); content = content.replace("${logging.event.user.logger}", USER_EVENT_LOGGER_NAME); content = content.replace("${logging.event.admin.logger}", ADMIN_EVENT_LOGGER_NAME); if (!f.getParentFile().mkdirs() && !f.getParentFile().canWrite()) { throw new IOException("Not allowed to write logging configuration file to " + f.getParent()); } else { IOUtil.writeString(content, f); } } return f; }