List of usage examples for java.util Properties load
public synchronized void load(InputStream inStream) throws IOException
From source file:br.com.ingenieux.jenkins.plugins.awsebdeployment.Deployer.java
private static String getVersion() { if ("UNKNOWN".equals(VERSION)) { try {//from w ww . ja v a 2 s . c om Properties p = new Properties(); p.load(Deployer.class.getResourceAsStream("version.properties")); VERSION = p.getProperty("awseb-deployer-plugin.version"); } catch (Exception exc) { throw new RuntimeException(exc); } } return VERSION; }
From source file:com.intel.cryptostream.utils.NativeCodeLoader.java
/** * Get the cryptostream version by reading pom.properties embedded in jar. * This version data is used as a suffix of a dll file extracted from the * jar.//from ww w. j a v a 2 s .co m * * @return the version string */ public static String getVersion() { URL versionFile = NativeCodeLoader.class .getResource("/META-INF/maven/com.intel.cryptostream/cryptostream/pom.properties"); if (versionFile == null) versionFile = NativeCodeLoader.class.getResource("/com/intel/cryptostream/VERSION"); String version = "unknown"; try { if (versionFile != null) { Properties versionData = new Properties(); versionData.load(versionFile.openStream()); version = versionData.getProperty("version", version); if (version.equals("unknown")) version = versionData.getProperty("VERSION", version); version = version.trim().replaceAll("[^0-9M\\.]", ""); } } catch (IOException e) { System.err.println(e); } return version; }
From source file:com.wavemaker.common.util.SystemUtils.java
public static Properties loadPropertiesFromStream(InputStream inputStream) { try {/*ww w .ja v a 2 s .com*/ Properties rtn = new Properties(); rtn.load(inputStream); return rtn; } catch (IOException ex) { throw new RuntimeException(ex); } }
From source file:common.DBHelper.java
public static DataSource getDataSource() { Properties prop = new Properties(); try (InputStream input = DBHelper.class.getResourceAsStream("/config.PROPERTIES");) { prop.load(input); } catch (IOException e) { logger.error("error reading properties", e); }/*from w w w . j a va2 s .com*/ BasicDataSource ds = new BasicDataSource(); ds.setUrl(prop.getProperty("dbUrl")); ds.setDriverClassName("org.apache.derby.jdbc.ClientDriver"); ds.setUsername(prop.getProperty("dbUsername")); ds.setPassword(prop.getProperty("dbPassword")); return ds; }
From source file:edu.kit.checkstyle.Main.java
/** * Loads properties from a File.//ww w . j a va2 s . co m * @param aFile the properties file * @return the properties in aFile */ private static Properties loadProperties(File aFile) { final Properties properties = new Properties(); FileInputStream fis = null; try { fis = new FileInputStream(aFile); properties.load(fis); } catch (final IOException ex) { System.out.println("Unable to load properties from file: " + aFile.getAbsolutePath()); ex.printStackTrace(System.out); System.exit(1); } finally { Utils.closeQuietly(fis); } return properties; }
From source file:com.scottjjohnson.finance.analysis.HttpClient.java
/** * Extracts http connection properties from the configuration file and returns them as a Properties object. * /*from w w w .ja v a 2 s . com*/ * @returns map of cookie key-value pairs (never null) */ public static Properties getDefaultConnectionProperties() { Properties connectionProps = new Properties(); try { ClassLoader loader = HttpClient.class.getClassLoader(); connectionProps.load(loader.getResourceAsStream(CONNECTION_CONFIG_PROPERTIES_FILE)); LOGGER.debug("Connection configuration properties: {}.", connectionProps); } catch (IOException e) { LOGGER.warn("Unable to load connection properties from {}.", CONNECTION_CONFIG_PROPERTIES_FILE); } return connectionProps; }
From source file:gaffer.graph.hook.OperationAuthoriser.java
private static Properties readProperties(final InputStream stream) { final Properties props = new Properties(); if (null != stream) { try {//w w w .j ava 2s.c om props.load(stream); } catch (IOException e) { throw new IllegalArgumentException("Failed to load store properties file : " + e.getMessage(), e); } finally { IOUtils.closeQuietly(stream); } } return props; }
From source file:com.gs.obevo.api.platform.ToolVersion.java
public static synchronized String getToolVersion() { if (TOOL_VERSION == null) { Properties props = new Properties(); try {//from w ww . j a v a 2 s . com URL resource = Validate.notNull(ToolVersion.class.getClassLoader().getResource(PROPERTY_PATH), "Could not read the required propertyPath: " + PROPERTY_PATH); props.load(resource.openStream()); } catch (IOException e) { throw new RuntimeException("Could not open the required propertyPath: " + PROPERTY_PATH, e); } TOOL_VERSION = props.getProperty("tool.version"); } return TOOL_VERSION; }
From source file:keel.Algorithms.Genetic_Rule_Learning.Tan_GP.Main.java
/** * <p>//from w w w . java2s . com * Configure the execution of the algorithm. * * @param jobFilename Name of the KEEL file with properties of the * execution * </p> */ private static void configureJob(String jobFilename) { Properties props = new Properties(); try { InputStream paramsFile = new FileInputStream(jobFilename); props.load(paramsFile); paramsFile.close(); } catch (IOException ioe) { ioe.printStackTrace(); System.exit(0); } // Files training and test String trainFile; String testFile; StringTokenizer tokenizer = new StringTokenizer(props.getProperty("inputData")); tokenizer.nextToken(); trainFile = tokenizer.nextToken(); trainFile = trainFile.substring(1, trainFile.length() - 1); testFile = tokenizer.nextToken(); testFile = testFile.substring(1, testFile.length() - 1); tokenizer = new StringTokenizer(props.getProperty("outputData")); String reportTrainFile = tokenizer.nextToken(); reportTrainFile = reportTrainFile.substring(1, reportTrainFile.length() - 1); String reportTestFile = tokenizer.nextToken(); reportTestFile = reportTestFile.substring(1, reportTestFile.length() - 1); String reportRulesFile = tokenizer.nextToken(); reportRulesFile = reportRulesFile.substring(1, reportRulesFile.length() - 1); // Algorithm auxiliar configuration XMLConfiguration algConf = new XMLConfiguration(); algConf.setRootElementName("experiment"); algConf.addProperty("process[@algorithm-type]", "net.sourceforge.jclec.problem.classification.tan.TanAlgorithm"); algConf.addProperty("process.rand-gen-factory[@type]", "net.sourceforge.jclec.util.random.RanecuFactory"); algConf.addProperty("process.rand-gen-factory[@seed]", Integer.parseInt(props.getProperty("seed"))); algConf.addProperty("process.population-size", Integer.parseInt(props.getProperty("population-size"))); algConf.addProperty("process.max-of-generations", Integer.parseInt(props.getProperty("max-generations"))); algConf.addProperty("process.max-deriv-size", Integer.parseInt(props.getProperty("max-deriv-size"))); algConf.addProperty("process.dataset[@type]", "net.sourceforge.jclec.util.dataset.KeelDataSet"); algConf.addProperty("process.dataset.train-data.file-name", trainFile); algConf.addProperty("process.dataset.test-data.file-name", testFile); algConf.addProperty("process.species[@type]", "net.sourceforge.jclec.problem.classification.tan.TanSyntaxTreeSpecies"); algConf.addProperty("process.evaluator[@type]", "net.sourceforge.jclec.problem.classification.tan.TanEvaluator"); algConf.addProperty("process.evaluator.w1", Double.parseDouble(props.getProperty("w1"))); algConf.addProperty("process.evaluator.w2", Double.parseDouble(props.getProperty("w2"))); algConf.addProperty("process.provider[@type]", "net.sourceforge.jclec.syntaxtree.SyntaxTreeCreator"); algConf.addProperty("process.parents-selector[@type]", "net.sourceforge.jclec.selector.RouletteSelector"); algConf.addProperty("process.recombinator[@type]", "net.sourceforge.jclec.syntaxtree.SyntaxTreeRecombinator"); algConf.addProperty("process.recombinator[@rec-prob]", Double.parseDouble(props.getProperty("rec-prob"))); algConf.addProperty("process.recombinator.base-op[@type]", "net.sourceforge.jclec.problem.classification.tan.TanCrossover"); algConf.addProperty("process.mutator[@type]", "net.sourceforge.jclec.syntaxtree.SyntaxTreeMutator"); algConf.addProperty("process.mutator[@mut-prob]", Double.parseDouble(props.getProperty("mut-prob"))); algConf.addProperty("process.mutator.base-op[@type]", "net.sourceforge.jclec.problem.classification.tan.TanMutator"); algConf.addProperty("process.copy-prob", Double.parseDouble(props.getProperty("copy-prob"))); algConf.addProperty("process.elitist-prob", Double.parseDouble(props.getProperty("elitist-prob"))); algConf.addProperty("process.support", Double.parseDouble(props.getProperty("support"))); algConf.addProperty("process.listener[@type]", "net.sourceforge.jclec.problem.classification.tan.KeelTanPopulationReport"); algConf.addProperty("process.listener.report-dir-name", "./"); algConf.addProperty("process.listener.train-report-file", reportTrainFile); algConf.addProperty("process.listener.test-report-file", reportTestFile); algConf.addProperty("process.listener.rules-report-file", reportRulesFile); algConf.addProperty("process.listener.global-report-name", "resumen"); algConf.addProperty("process.listener.report-frequency", 50); try { algConf.save(new File("configure.txt")); } catch (ConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } net.sourceforge.jclec.RunExperiment.main(new String[] { "configure.txt" }); }
From source file:com.adaptris.core.MimeEncoder.java
private static Set<MetadataElement> getMetadataSet(InputStream in) throws IOException { Properties p = new Properties(); p.load(in); return convertFromProperties(p); }