List of usage examples for java.util Properties load
public synchronized void load(InputStream inStream) throws IOException
From source file:model.PayloadSequences.java
/** * @param data// w w w .j av a 2s . com * @return Properties class form byte array */ public static Properties getEncapsulationMetadataProperties(byte[] data) { Properties properties = new Properties(); try { properties.load(new ByteArrayInputStream(data)); } catch (IOException e) { e.printStackTrace(); } return properties; }
From source file:gov.nih.nci.integration.catissue.CaTissueConsentIntegrationTest.java
/** * To initialize the things//from w w w . j ava2s .co m * @throws IOException */ @BeforeClass public static void initialize() throws IOException { try { Properties props = new Properties(); props.load(Thread.currentThread().getContextClassLoader() .getResourceAsStream("transcend-ihub-test.properties")); String catissueUserName = props.getProperty("catissue.api.login.username"); String catissuePassword = props.getProperty("catissue.api.login.password"); caTissueParticipantClient = new CaTissueParticipantClient(catissueUserName, catissuePassword); caTissueSpecimenClient = new CaTissueSpecimenClient(catissueUserName, catissuePassword); caTissueConsentClient = new CaTissueConsentClient(catissueUserName, catissuePassword); } catch (BeansException e) { LOG.error("CaTissueConsentIntegrationTest-BeansException inside initialize() ", e); } catch (MalformedURLException e) { LOG.error("CaTissueConsentIntegrationTest-ApplicationException inside initialize() ", e); } }
From source file:com.beginner.core.utils.PropertyUtil.java
/** * ?Properties?//w ww . j a va 2 s.c o m * @param fileName :beginner.properties * @return Properties ? * @throws Exception IO */ public static Properties getObj(String fileName) throws Exception { Properties properties = new Properties(); properties.load(PropertyUtil.class.getClassLoader().getResourceAsStream(fileName)); return properties; }
From source file:com.beginner.core.utils.PropertyUtil.java
/** * ?Properties?/* w ww . j av a 2 s . co m*/ * @param fileName :/data/resources/beginner.properties * @return Properties ? * @throws Exception IO */ public static Properties getObjExternal(String fileName) throws Exception { Properties properties = new Properties(); properties.load(new FileInputStream(fileName)); return properties; }
From source file:com.facebook.tsdb.tsdash.server.TsdbServlet.java
private static void loadConfiguration() { Properties tsdbConf = new Properties(); try {/*from w w w .j a v a 2 s.c om*/ PropertyConfigurator.configure(LOG4J_PROPERTIES_FILE); tsdbConf.load(new FileInputStream(PROPERTIES_FILE)); HBaseConnection.configure(tsdbConf); URLPattern = tsdbConf.getProperty(URL_PATTERN_PARAM, DEFAULT_URL_PATTERN); logger.info("URL pattern: " + URLPattern); plotsDir = tsdbConf.getProperty(PLOTS_DIR_PARAM, DEFAULT_PLOTS_DIR); logger.info("Plots are being written to: " + plotsDir); } catch (FileNotFoundException e) { System.err.println("Cannot find " + PROPERTIES_FILE); } catch (IOException e) { System.err.println("Cannot read " + PROPERTIES_FILE); } }
From source file:com.magnet.mmx.server.plugin.mmxmgmt.util.DBTestUtil.java
public static void setDataSourceFromPropertyFile() 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 va 2 s.co m ds.setUsername(user); ds.setPassword(password); ds.setUrl(url); }
From source file:com.handany.base.generator.Generator.java
public static List<TableBean> getTables() { Properties p = new Properties(); try {//w w w. j a v a 2s. c om p.load(new FileInputStream(new File("src/main/java/com/handany/base/generator/generator.properties"))); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<TableBean> tableBeanList = jdbcTemplate.query("select * from TABLES where table_schema = ?", new Object[] { SCHEMA_NAME }, new RowMapper<TableBean>() { @Override public TableBean mapRow(ResultSet rs, int i) throws SQLException { TableBean bean = new TableBean(); String tableName = rs.getString("table_name"); bean.setTableName(tableName); bean.setTableNameNoDash(delDash(tableName)); bean.setTableNameCapitalized(StringUtils.capitalize(bean.getTableNameNoDash())); bean.setTableComment(rs.getString("table_comment")); return bean; } }); for (TableBean tableBean : tableBeanList) { tableBean.setColumnBeanList(getColumns(tableBean)); } return tableBeanList; }
From source file:org.openbaton.autoscaling.utils.Utils.java
public static void loadExternalProperties(ConfigurableEnvironment properties) { if (properties.containsProperty("external-properties-file") && properties.getProperty("external-properties-file") != null) { try {/* ww w . j ava 2 s. c om*/ InputStream is = new FileInputStream(new File(properties.getProperty("external-properties-file"))); Properties externalProperties = new Properties(); externalProperties.load(is); PropertiesPropertySource propertiesPropertySource = new PropertiesPropertySource( "external-properties", externalProperties); MutablePropertySources propertySources = properties.getPropertySources(); propertySources.addFirst(propertiesPropertySource); } catch (IOException e) { log.warn("Not found external-properties-file: " + properties.getProperty("external-properties-file")); } } }
From source file:net.sf.jasperreports.engine.util.DefaultedMessageProvider.java
protected static Properties loadResourceProperties(String defaultsResource) { InputStream in = JRLoader.getResourceInputStream(defaultsResource); Properties defaults = null; if (in != null) { try {//from ww w .j a va2 s .c o m defaults = new Properties(); defaults.load(in); } catch (IOException e) { throw new JRRuntimeException(e); } finally { try { in.close(); } catch (IOException e) { log.debug("Failed to close stream for " + defaultsResource, e); } } } else { if (log.isDebugEnabled()) { log.debug("Did not find default messages resource " + defaultsResource); } } return defaults; }
From source file:Main.java
public static Document parseFile(final File aFile, final String propfilename) throws SAXException, ParserConfigurationException { Properties props; props = new Properties(); try {//from ww w . j a v a2s . co m InputStream propsStream = new FileInputStream(propfilename); props.load(propsStream); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex1) { ex1.printStackTrace(); } return parseFile(aFile, props); }