List of usage examples for java.util Properties load
public synchronized void load(InputStream inStream) throws IOException
From source file:gov.nih.nci.cabig.ctms.tools.configuration.DefaultConfigurationProperties.java
private static Properties loadDetails(Resource resource) { Properties details = new Properties(); try {//w w w . j a v a 2s.c o m details.load(resource.getInputStream()); } catch (IOException e) { throw new CommonsSystemException("Failed to load property details from " + resource, e); } return details; }
From source file:com.magnet.mmx.server.plugin.mmxmgmt.api.MMXVersionResourceTest.java
@BeforeClass public static void setupDatabase() throws Exception { java.util.logging.Logger.getLogger("com.google.inject").setLevel(java.util.logging.Level.SEVERE); org.apache.log4j.Logger.getLogger("org.apache.http").setLevel(org.apache.log4j.Level.DEBUG); org.apache.log4j.Logger.getLogger("org.jboss.resteasy").setLevel(Level.OFF); InputStream inputStream = MMXTopicTagsResourceTest.class.getResourceAsStream("/test.properties"); Properties testProperties = new Properties(); testProperties.load(inputStream); 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);/* w w w .jav a 2 s . com*/ ds.setUsername(user); ds.setPassword(password); ds.setUrl(url); DBTestUtil.setBasicDataSource(ds); new MockUp<AppDAOImpl>() { @Mock protected String getEncrypted(String value) { return value; } }; DBTestUtil.setupMockDBUtil(); appEntity = createRandomApp(); LOGGER.warn("Finished setupDatabase"); }
From source file:com.cisco.dbds.utils.configfilehandler.ConfigFileHandler.java
/** * Sets the systemvariable.// ww w .j a v a 2s . co m * * @param input the new systemvariable */ public static void setSystemvariable(InputStream input) { Properties tmp1 = new Properties(); try { tmp1.load(input); for (Object element : tmp1.keySet()) { System.setProperty(element.toString().trim(), tmp1.getProperty(element.toString().trim()).trim()); } } catch (IOException e) { System.out.println("setSystemvariable method failure"); } }
From source file:com.jkoolcloud.tnt4j.streams.custom.kafka.interceptors.InterceptorsTest.java
private static Producer<String, String> initProducer() throws Exception { Properties props = new Properties(); props.load(new FileReader(System.getProperty("producer.config")));// NON-NLS eventsToProduce = Utils.getInt("events.count", props, 10); props.remove("events.count"); topicName = props.getProperty("test.app.topic.name", "tnt4j_streams_kafka_intercept_test_page_visits"); // NON-NLS props.remove("test.app.topic.name"); Producer<String, String> producer = new KafkaProducer<>(props); return producer; }
From source file:net.ripe.rpki.validator.util.TrustAnchorLocator.java
private static TrustAnchorLocator readExtendedTrustAnchorLocator(File file, String contents) throws IOException, URISyntaxException { Properties p = new Properties(); p.load(new StringReader(contents)); String caName = p.getProperty("ca.name"); String loc = p.getProperty("certificate.location"); Validate.notEmpty(loc, "'certificate.location' must be provided"); URI location = new URI(loc); String publicKeyInfo = p.getProperty("public.key.info", "").replaceAll("\\s+", ""); String[] uris = p.getProperty("prefetch.uris", "").split(","); List<URI> prefetchUris = new ArrayList<URI>(uris.length); for (String uri : uris) { uri = uri.trim();/*ww w .j a v a 2 s. co m*/ if (StringUtils.isNotBlank(uri)) { if (!uri.endsWith("/") && uri.startsWith("rsync://")) { uri += "/"; } prefetchUris.add(new URI(uri)); } } return new TrustAnchorLocator(file, caName, location, publicKeyInfo, prefetchUris); }
From source file:com.magnet.mmx.server.plugin.mmxmgmt.db.TopicDaoImplTest.java
@BeforeClass public static void setupDatabase() throws Exception { InputStream inputStream = DeviceDAOImplTest.class.getResourceAsStream("/test.properties"); Properties testProperties = new Properties(); testProperties.load(inputStream); 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);/*from ww w . j a v a2 s. c o m*/ ds.setUsername(user); ds.setPassword(password); ds.setUrl(url); DBTestUtil.setBasicDataSource(ds); }
From source file:com.cslc.eils.gameControl.util.PropertiesUtil.java
/** * /*from w w w . j a v a2s .c o m*/ * * @param propFileUrl * * @return */ public static Properties loadProperties(String propFileUrl) { log.info(":" + propFileUrl); InputStream in = null; try { File path = new File(propFileUrl); if (!path.exists()) { // TODO Throws exp } else { Properties properties = new Properties(); in = new FileInputStream(path); properties.load(in); return properties; } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (in != null) { try { in.close(); } catch (IOException ioe) { ioe.printStackTrace(); } } } return null; }
From source file:edu.cornell.mannlib.ld4lindexing.Ld4lIndexer.java
private static void initializeLogging() throws StartupException { try {//from w w w.j a v a 2 s.co m LogManager.resetConfiguration(); Properties props = new Properties(); props.load(new FileInputStream(PATH_TO_LOG4J_PROPERTIES)); PropertyConfigurator.configure(props); } catch (IOException e) { throw new LoggingSetupException(e); } }
From source file:Main.java
/** Loads properties into a file. * <P>This assumes the file was written with the * <code>Properties.store()</code> method. *//* w ww .jav a2s . co m*/ public static void load(Properties p, File file) throws IOException { InputStream in = null; try { in = new FileInputStream(file); p.load(in); } finally { if (in != null) { try { in.close(); } catch (Throwable t) { } } } }
From source file:lichen.orm.LichenOrmModule.java
public static DataSource buildDataSource(@Symbol(LichenOrmSymbols.DATABASE_CFG_FILE) String dbCfgFile, RegistryShutdownHub shutdownHub) throws IOException, ProxoolException { ResourceLoader resourceLoader = new DefaultResourceLoader(); Resource resource = resourceLoader.getResource(dbCfgFile); Properties info = new Properties(); info.load(resource.getInputStream()); PropertyConfigurator.configure(info); String poolNameKey = F.flow(info.keySet()).filter(new Predicate<Object>() { public boolean accept(Object element) { return element.toString().contains("alias"); }//www . j av a 2 s. c o m }).first().toString(); if (poolNameKey == null) { throw new RuntimeException("?poolName"); } final String poolName = info.getProperty(poolNameKey); //new datasource ProxoolDataSource ds = new ProxoolDataSource(poolName); //register to shutdown shutdownHub.addRegistryShutdownListener(new RegistryShutdownListener() { public void registryDidShutdown() { Flow<?> flow = F.flow(ProxoolFacade.getAliases()).filter(new Predicate<String>() { public boolean accept(String element) { return element.equals(poolName); } }); if (flow.count() == 1) { try { ProxoolFacade.removeConnectionPool(poolName); } catch (ProxoolException e) { //do nothing } } } }); return ds; }