List of usage examples for java.util Properties getProperty
public String getProperty(String key)
From source file:com.google.mr4c.config.ConfigUtils.java
public static Set<String> findUnresolvedProperties(Properties props) { Set<String> result = new HashSet<String>(); for (String name : props.stringPropertyNames()) { String val = props.getProperty(name); if (containsVariables(val)) { result.add(name);/*from w w w. j a va 2 s. com*/ } } return result; }
From source file:Main.java
/** * Copies all elements from <code>properties</code> into the given <code>result</code>. * @param properties/* ww w . jav a2 s. c om*/ * @param result */ public static void putAll(Properties properties, Map<String, String> result) { for (Enumeration<Object> keys = properties.keys(); keys.hasMoreElements();) { String key = (String) keys.nextElement(); result.put(key, properties.getProperty(key)); } }
From source file:com.opengamma.examples.simulated.DBTestUtils.java
public static Properties loadProperties(String configResourceLocation) throws IOException { Resource resource = ResourceUtils.createResource(configResourceLocation); Properties props = new Properties(); props.load(resource.getInputStream()); String nextConfiguration = props.getProperty("MANAGER.NEXT.FILE"); if (nextConfiguration != null) { resource = ResourceUtils.createResource(nextConfiguration); Properties parentProps = new Properties(); parentProps.load(resource.getInputStream()); for (String key : props.stringPropertyNames()) { parentProps.put(key, props.getProperty(key)); }/*from ww w . j a v a2 s . co m*/ props = parentProps; } for (String key : props.stringPropertyNames()) { s_logger.debug("\t{}={}", key, props.getProperty(key)); } return props; }
From source file:com.google.mr4c.hadoop.HadoopUtils.java
public static void applyToJobConf(Properties props, JobConf conf) { for (String name : props.stringPropertyNames()) { conf.set(name, props.getProperty(name)); }//from w w w. ja v a 2 s .c o m }
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 a v a2 s .co m }
From source file:com.kamike.misc.FsUtils.java
public static void createDir(String dstPath) { Properties props = System.getProperties(); // String osName = props.getProperty("os.name"); //??? Path newdir = FileSystems.getDefault().getPath(dstPath); boolean pathExists = Files.exists(newdir, new LinkOption[] { LinkOption.NOFOLLOW_LINKS }); if (!pathExists) { Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxrwxrwx"); FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms); try {// www .j av a2 s. com if (!osName.contains("Windows")) { Files.createDirectories(newdir, attr); } else { Files.createDirectories(newdir); } } catch (Exception e) { System.err.println(e); } } }
From source file:de.uzk.hki.da.at.AcceptanceTest.java
private static void instantiateRepository(Properties properties) { String repImplBeanName = properties.getProperty("cb.implementation.repository"); if (repImplBeanName == null) repImplBeanName = "fakeRepositoryFacade"; AbstractApplicationContext context = new FileSystemXmlApplicationContext("conf/beans.xml"); repositoryFacade = (RepositoryFacade) context.getBean(repImplBeanName); context.close();/*www .j a v a2 s . c om*/ }
From source file:com.kamike.misc.FsUtils.java
public static void createDirectory(String dstPath) { Properties props = System.getProperties(); // String osName = props.getProperty("os.name"); //??? Path newdir = FileSystems.getDefault().getPath(dstPath); boolean pathExists = Files.exists(newdir, new LinkOption[] { LinkOption.NOFOLLOW_LINKS }); if (!pathExists) { Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxrwxrwx"); FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms); try {//from www .j av a 2 s .co m if (!osName.contains("Windows")) { Files.createDirectories(newdir, attr); } else { Files.createDirectories(newdir); } } catch (Exception e) { System.err.println(e); } } }
From source file:com.google.mr4c.config.execution.DirectoryConfig.java
private static String loadValue(Properties props, String name, String defaultValue) { String data = props.getProperty(name); if (data == null) { if (defaultValue == null) { throw new IllegalArgumentException("Missing " + name); } else {/*from ww w .ja va 2 s . c om*/ data = defaultValue; } } return StringUtils.strip(data); }
From source file:com.magnet.mmx.server.plugin.mmxmgmt.db.UserDAOImplTest.java
@BeforeClass public static void setupDatabase() throws Exception { InputStream inputStream = DeviceDAOImplTest.class.getResourceAsStream("/test.properties"); Properties testProperties = new Properties(); testProperties.load(inputStream);/*from w w w . j a v a2s . c o m*/ String host = testProperties.getProperty("db.host"); String port = testProperties.getProperty("db.port"); String user = testProperties.getProperty("db.user"); String password = testProperties.getProperty("db.password"); String driver = testProperties.getProperty("db.driver"); String schema = testProperties.getProperty("db.schema"); String url = "jdbc:mysql://" + host + ":" + port + "/" + schema; ds = new BasicDataSource(); ds.setDriverClassName(driver); ds.setUsername(user); ds.setPassword(password); ds.setUrl(url); DBTestUtil.setBasicDataSource(ds); generateRandomUserData(); }