List of usage examples for java.util Properties load
public synchronized void load(InputStream inStream) throws IOException
From source file:ConnectionUtil.java
/** Get a Connection for the given config using the default or set property file name */ public static Connection getConnection(String config) throws Exception { try {/*ww w.j a v a2 s . com*/ Properties p = new Properties(); p.load(new FileInputStream(configFileName)); return getConnection(p, config); } catch (IOException ex) { throw new Exception(ex.toString()); } }
From source file:Main.java
/** * Read config file./*from ww w . ja va 2 s . com*/ */ private static Properties loadConfig() { Properties properties = new Properties(); try { FileInputStream s = new FileInputStream(CONFIG_FILE_PATH); properties.load(s); } catch (Exception ex) { ex.printStackTrace(); } return properties; }
From source file:de.drippinger.serviceExtractor.CLIEntry.java
static RunParameter extractParameterFromConfigFile(CommandLine cmd) throws ExtractorException { RunParameter parameter = new RunParameter(); StandardPBEStringEncryptor encryptors = new StandardPBEStringEncryptor(); encryptors.setPassword(cmd.getOptionValue("s")); Properties properties = new EncryptableProperties(encryptors); try {/* w w w . j av a 2s . c o m*/ properties.load(new FileInputStream(cmd.getOptionValue("c"))); parameter.database(properties.getProperty("datasource.url")) .databaseUser(properties.getProperty("datasource.username")) .databasePassword(properties.getProperty("datasource.password")) .pathToFlows(properties.getProperty("wm.pathToFlows")); } catch (IOException e) { throw new ExtractorException("Could not load property file", e); } return parameter; }
From source file:Main.java
/** * Reads Properties from given inputStream and returns it. * NOTE: the given stream is closed by this method */// www . jav a 2 s . c o m public static Properties readProperties(InputStream is, Properties props) throws IOException { if (props == null) props = new Properties(); try { props.load(is); } finally { is.close(); } return props; }
From source file:com.xinlv.test.PortalTestUtil.java
public static String[] getMessage(String key, Class<?> clazz) { Properties prop = new Properties(); try {//from w w w . j a va 2 s . c o m prop.load(clazz.getResourceAsStream(clazz.getSimpleName() + ".properties")); } catch (IOException e) { // do nothing } return new String[] { prop.getProperty(key) }; }
From source file:com.splunk.shuttl.archiver.filesystem.glacier.AWSCredentialsImpl.java
/** * @param properties/*ww w . j av a 2 s . co m*/ * file containing amazon properties for all the fields. */ public static AWSCredentialsImpl createWithPropertyFile(File amazonProperties) { try { Properties properties = new Properties(); properties.load(FileUtils.openInputStream(amazonProperties)); String id = properties.getProperty("aws.id"); String secret = properties.getProperty("aws.secret"); String bucket = properties.getProperty("s3.bucket"); String vault = properties.getProperty("glacier.vault"); String endpoint = properties.getProperty("glacier.endpoint"); return new AWSCredentialsImpl(id, secret, endpoint, bucket, vault); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:Main.java
private static String getVerNameFromAssert(Context context) { String versionName = ""; try {/* ww w . j a v a 2 s. c om*/ Properties pro = new Properties(); InputStream is = context.getAssets().open("channel.properties"); pro.load(is); String tmpVersionName = pro.getProperty("versionName"); versionName = new String(tmpVersionName.getBytes("ISO-8859-1"), "UTF-8"); is.close(); is = null; } catch (Exception e) { versionName = ""; Log.e(TAG, "AppConfig.loadVersion have Exception e = " + e.getMessage()); } return versionName; }
From source file:ch.algotrader.config.spring.ConfigLoader.java
static void loadResource(final Map<String, String> paramMap, final Resource resource) throws IOException { try (InputStream inputStream = resource.getInputStream()) { Properties props = new Properties(); props.load(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); for (Map.Entry<Object, Object> entry : props.entrySet()) { String paramName = (String) entry.getKey(); String paramValue = (String) entry.getValue(); if (StringUtils.isNotBlank(paramName)) { paramMap.put(paramName, paramValue); }//w ww .j a v a 2s . c o m } } }
From source file:com.github.peholmst.springsecuritydemo.VersionInfo.java
private static void readApplicationVersion() { if (logger.isDebugEnabled()) { logger.debug("Attempting to read application version from 'version.properties'"); }/*ww w . j ava2s. c om*/ InputStream is = VersionInfo.class.getResourceAsStream("/version.properties"); if (is != null) { Properties props = new Properties(); try { props.load(is); version = props.getProperty("app.version"); if (version != null) { if (logger.isInfoEnabled()) { logger.info("Application version is '" + version + "'"); } return; } } catch (IOException e) { if (logger.isErrorEnabled()) { logger.error("Could not load version properties", e); } } } if (logger.isWarnEnabled()) { logger.warn("Could not retrieve a version number, using 'unversioned'"); } version = "unversioned"; }
From source file:hudson.plugins.parameterizedtrigger.ParameterizedTriggerUtils.java
/** * Load properties from string.//from w ww. j av a2 s . c o m * Extracted for sanitize JRE dependency. * * @param properties * @return * @throws IOException */ @IgnoreJRERequirement public static Properties loadProperties(String properties) throws IOException { Properties p = new Properties(); try { p.load(new StringReader(properties)); } catch (NoSuchMethodError _) { // {@link Properties#load(java.io.Reader)} is supported since Java 1.6 // When used with Java1.5, fall back to // {@link Properties#load(java.io.InputStream)}, which does not support // Non-ascii strings. p.load(new StringInputStream(properties)); } return p; }