List of usage examples for java.util Properties load
public synchronized void load(InputStream inStream) throws IOException
From source file:de.ingrid.interfaces.csw.admin.command.AdminManager.java
/** * Read the override configuration and write a new bcrypt-hash password. *///from ww w.jav a2s.co m private static void resetPassword(String newPassword) { try { InputStream is = new FileInputStream("conf/config.override.properties"); Properties props = new Properties(); props.load(is); props.setProperty("ingrid.admin.password", BCrypt.hashpw(newPassword, 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:agency.Agency.java
private static DataSource prepareDataSource() throws SQLException, IOException { Properties myconf = new Properties(); myconf.load(Agency.class.getResourceAsStream("/myconf.properties")); BasicDataSource ds = new BasicDataSource(); ds.setUrl(myconf.getProperty("jdbc.url")); ds.setUsername(myconf.getProperty("jdbc.user")); ds.setPassword(myconf.getProperty("jdbc.password")); return ds;/* w w w.j av a 2s. c o m*/ }
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 */// ww w. j a v a2 s. c om 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:ca.uhn.fhir.util.VersionUtil.java
private static void initialize() { InputStream is = null;// w w w .j a v a 2 s .c o m try { is = VersionUtil.class.getResourceAsStream("/ca/uhn/fhir/hapi-version.properties"); Properties p = new Properties(); p.load(is); ourVersion = p.getProperty("version"); ourLog.info("HAPI FHIR version is: " + ourVersion); } catch (Exception e) { ourLog.warn("Unable to determine HAPI version information", e); } finally { IOUtils.closeQuietly(is); } }
From source file:com.alibaba.cobar.manager.qa.modle.CobarFactory.java
public static SimpleCobarNode getSimpleCobarNode(String cobarNodeName) throws Exception { Properties prop = new Properties(); prop.load(CobarFactory.class.getClassLoader().getResourceAsStream("cobarNode.properties")); String user = prop.getProperty(cobarNodeName + ".user").trim(); String password = prop.getProperty(cobarNodeName + ".password").trim(); String ip = prop.getProperty(cobarNodeName + ".ip").trim(); int dmlPort = Integer.parseInt(prop.getProperty(cobarNodeName + ".dml.port").trim()); int managerPort = Integer.parseInt(prop.getProperty(cobarNodeName + ".manager.port").trim()); SimpleCobarNode sCobarNode = new SimpleCobarNode(ip, dmlPort, managerPort, user, password); return sCobarNode; }
From source file:com.netflix.iep.config.TestResourceConfiguration.java
public static void load(String propFile, Map<String, String> subs, Map<String, String> overrides) throws IOException { URL propUrl = Resources.getResource(propFile); String propData = Resources.toString(propUrl, Charsets.UTF_8); for (Map.Entry e : subs.entrySet()) { propData = propData.replaceAll("\\{" + e.getKey() + "\\}", (String) e.getValue()); }//from w w w . j a va 2s .c om final Properties props = new Properties(); props.load(new ByteArrayInputStream(propData.getBytes())); for (Map.Entry e : overrides.entrySet()) { props.setProperty((String) e.getKey(), (String) e.getValue()); } ConfigurationManager.getConfigInstance().clear(); ConfigurationManager.loadProperties(props); }
From source file:Main.java
public static Properties loadProperties(Context context, String file, String encode) throws Exception { Properties properties = new Properties(); FileInputStream s = new FileInputStream(file); properties.load(s); return properties; }
From source file:com.khs.sherpa.util.Util.java
public static Properties getProperties(URL url) throws IOException { Properties properties = new Properties(); properties.load(url.openStream()); return properties; }
From source file:edu.pitt.dbmi.ipm.service.EnterpriseAnalytics.java
/** * Initializes parameters from *.conf file based on selected storage * parameter 'useVitOrPostgre' in jQueryPostgres.conf file *//*from w ww . j av a 2 s . co m*/ private static void initParams() { if (!hasParams) { hasParams = true; try { StorageFactory.getStorage().initParameters(); hasParams = true; Properties params = new Properties(); params.load(new FileInputStream(System.getProperty("user.dir") + File.separator + "resources" + File.separator + StorageFactory.getStorage().getConfFileName())); String prefix_name = params.getProperty("prefix_name"); String prefix = params.getProperty("prefix"); count_patients_by_tss_Q = DataSelection .queryInitReplace(params.getProperty("count_patients_by_tss"), prefix_name, prefix); } catch (Exception ex) { System.out.println(ex.getMessage()); } } }
From source file:com.antonjohansson.elasticsearchshell.utils.PropertiesUtils.java
/** * Reads properties from the given file. *//*from w w w.j a va2 s.c o m*/ public static Properties read(File file) { InputStream input = null; try { input = new FileInputStream(file); Properties properties = new Properties(); properties.load(input); return properties; } catch (Exception e) { throw new RuntimeException(e); } finally { closeQuietly(input); } }