List of usage examples for java.util Properties store
public void store(OutputStream out, String comments) throws IOException
From source file:edu.ku.brc.util.XMLChecksumUtil.java
/** * Creates the Checksum properties file in the config directory. * @param files the list of files to be checksumed *///from w w w . j a v a2 s . co m public static void createChecksumProps(final File[] files) { Properties checksumProps = new Properties(); File checksumFile = XMLHelper.getConfigDir(checksumFileName); try { createChecksumProps(checksumProps, files); checksumProps.store(new FileOutputStream(checksumFile), "Checksum Properties"); } catch (IOException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(XMLChecksumUtil.class, ex); throw new RuntimeException("Couldn't locate Checksum file [" + checksumFile.getAbsolutePath() + "]"); } }
From source file:com.omertron.fanarttvapi.TestLogger.java
/** * Save properties to a file//www.j a va 2 s . c o m * * @param props * @param propertyFile * @param headerText */ public static void saveProperties(Properties props, File propertyFile, String headerText) { OutputStream out = null; try { out = new FileOutputStream(propertyFile); if (StringUtils.isNotBlank(headerText)) { props.store(out, headerText); } } catch (FileNotFoundException ex) { LOG.warn("Failed to find properties file", ex); } catch (IOException ex) { LOG.warn("Failed to read properties file", ex); } finally { if (out != null) { try { out.flush(); out.close(); } catch (IOException ex) { LOG.warn("Failed to close properties file", ex); } } } }
From source file:com.googleapis.ajax.services.example.ResourceBundleGenerator.java
private static void saveResourceMessages(Properties translatedResources, String fileName, Language language) { FileOutputStream os = null;/*w w w. jav a 2 s. c om*/ try { os = new FileOutputStream(fileName + "_" + language.value() + ".properties"); translatedResources.store(os, "Resources for " + language); } catch (Exception ex) { ex.printStackTrace(); } finally { if (os != null) { try { os.close(); } catch (Exception e) { } } } }
From source file:com.sonicle.webtop.core.app.util.LogbackHelper.java
public static void writeProperties(ClassLoader classLoader, Properties properties) throws IOException, URISyntaxException { FileOutputStream out = null;/*from ww w. j a va 2s. c om*/ try { out = new FileOutputStream(new File(classLoader.getResource(LOGBACK_PROPERTIES_FILE).toURI())); properties.store(out, ""); } finally { IOUtils.close(out); } }
From source file:Main.java
/** Writes a <code>Properties</code> object to * a <code>File</code>.//from w w w .j av a 2 s. co m */ public static void write(Properties p, File file) throws IOException { OutputStream out = null; try { out = new FileOutputStream(file); p.store(out, ""); } finally { if (out != null) { try { out.close(); } catch (Throwable t) { } } } }
From source file:Main.java
public static void saveAccount(Activity act, String account, String psw) { String str = account + "," + psw; Properties localProperties = new Properties(); localProperties.put("account", str); try {/*from w w w. j ava2 s . co m*/ File file = new File(act.getFilesDir() + "/accout.cfg"); if (!file.exists()) file.createNewFile(); FileOutputStream localFileOutputStream = act.openFileOutput("account.cfg", Context.MODE_PRIVATE); localProperties.store(localFileOutputStream, ""); localFileOutputStream.close(); } catch (Exception localException) { localException.printStackTrace(); } }
From source file:Main.java
public static boolean storePropertyInstance(String filePath, String fileName, Properties p, String comment) { try {/*from w w w. j a v a 2 s . c o m*/ File d = new File(filePath); if (!d.exists()) { d.mkdirs(); } File f = new File(d, fileName); if (!f.exists()) { f.createNewFile(); } OutputStream os = new FileOutputStream(f); p.store(os, comment); os.close(); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
From source file:de.ingrid.interfaces.csw.admin.command.AdminManager.java
/** * Read the override configuration and convert the clear text password to a bcrypt-hash, * which is used and needed by the base-webapp v3.6.1 *//*from www . j a v a 2s. c o m*/ private static void migratePassword() { try { InputStream is = new FileInputStream("conf/config.properties"); Properties props = new Properties(); props.load(is); String oldPassword = props.getProperty("ingrid.admin.password"); is.close(); props.setProperty("ingrid.admin.password", BCrypt.hashpw(oldPassword, BCrypt.gensalt())); OutputStream os = new FileOutputStream("conf/config.override.properties"); props.store(os, "Override configuration written by the application"); os.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:energy.usef.environment.tool.util.FileUtil.java
public static Properties writeProperties(String configFilename, String comment, Properties properties) throws IOException { LOGGER.info("Writing properties file: {}", configFilename); try (FileOutputStream output = new FileOutputStream(configFilename);) { properties.store(output, comment); }//from ww w.jav a 2 s.c o m return properties; }
From source file:net.firejack.platform.core.utils.MiscUtils.java
/** * @param properties//w ww . ja v a 2s . com * @param checkFileExists * @param property * @param value * @throws java.io.IOException */ public static void setProperties(File properties, boolean checkFileExists, String property, String value) throws IOException { if (checkFileExists && !properties.exists()) { logger.error("Properties file [" + properties.getAbsolutePath() + "] does not exist."); throw new FileNotFoundException("Properties file does not found."); // IOHelper.delete(dbProperties); } Properties props = new Properties(); if (properties.exists()) { FileReader reader = new FileReader(properties); props.load(reader); reader.close(); } props.put(property, value); FileWriter writer = new FileWriter(properties); props.store(writer, null); writer.flush(); writer.close(); }