List of usage examples for java.util Properties load
public synchronized void load(InputStream inStream) throws IOException
From source file:com.textocat.textokit.commons.io.IoUtils.java
public static Properties readProperties(File inFile, String encoding) throws IOException { Properties props = new Properties(); BufferedReader r = openReader(inFile, encoding); try {//from ww w . j a v a 2s . co m props.load(r); } finally { closeQuietly(r); } return props; }
From source file:com.izforge.izpack.util.LogUtils.java
private static void loadLoggingResource(InputStream resourceStream, Variables variables) throws IOException { if (resourceStream != null) { InputStream is = variables != null ? new VariableSubstitutorInputStream(resourceStream, null, variables, SubstitutionType.TYPE_JAVA_PROPERTIES, false) : resourceStream;//from w w w . jav a 2 s . co m final Properties props = new Properties(); props.load(is); loadConfiguration(props); } }
From source file:com.textocat.textokit.eval.EvaluationLauncher.java
private static Properties readProperties(File srcFile) throws IOException { Properties result = new Properties(); InputStream srcIS = new FileInputStream(srcFile); Reader srcReader = new BufferedReader(new InputStreamReader(srcIS, "utf-8")); try {/*from w w w . j a va 2s.co m*/ result.load(srcReader); } finally { IOUtils.closeQuietly(srcReader); } return result; }
From source file:net.firejack.platform.core.utils.MiscUtils.java
/** * @param properties/*from w w w .j av a 2 s. c o m*/ * @param append * @throws java.io.IOException */ public static void setProperties(File properties, Map<String, String> append) throws IOException { Properties props = new Properties(); if (properties.exists()) { FileReader reader = new FileReader(properties); props.load(reader); reader.close(); } else { FileUtils.forceMkdir(properties.getParentFile()); } if (properties.exists() || properties.createNewFile()) { props.putAll(append); FileWriter writer = new FileWriter(properties); props.store(writer, null); writer.flush(); writer.close(); } }
From source file:net.firejack.platform.core.utils.MiscUtils.java
/** * @param properties/*from ww w .j a v a2 s. c o m*/ * @param checkFileExists * @param property * @param value * @throws java.io.IOException */ public static void setProperties(File properties, boolean checkFileExists, String property, String value) throws IOException { if (checkFileExists && !properties.exists()) { logger.error("Properties file [" + properties.getAbsolutePath() + "] does not exist."); throw new FileNotFoundException("Properties file does not found."); // IOHelper.delete(dbProperties); } Properties props = new Properties(); if (properties.exists()) { FileReader reader = new FileReader(properties); props.load(reader); reader.close(); } props.put(property, value); FileWriter writer = new FileWriter(properties); props.store(writer, null); writer.flush(); writer.close(); }
From source file:com.autentia.tnt.version.Version.java
public static Version getApplicationVersion() { if (appVersion == null) { try {/*w ww .j a va2 s .c o m*/ InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream("com/autentia/tnt/version/info.properties"); Properties props = new Properties(); props.load(is); appVersion = new Version(props.getProperty("number")); } catch (Exception e) { log.fatal("static - cannot read version", e); } } return appVersion; }
From source file:it.geosolutions.geobatch.opensdi.csvingest.utils.CSVSchemaHandler.java
/** * Load a properties File and save the values in a Map * @param fileURL//from w ww .j a v a 2 s. co m * @return */ public static Map<String, String> loadProperties(File properties) { InputStream inStream = null; Map<String, String> propertiesMap = null; try { inStream = new FileInputStream(properties); Properties p = new Properties(); p.load(inStream); propertiesMap = new HashMap<String, String>((Map) p); } catch (FileNotFoundException e) { LOGGER.error(e.getMessage(), e); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } finally { if (inStream != null) { try { inStream.close(); } catch (IOException e) { inStream = null; LOGGER.error(e.getMessage(), e); } } } return propertiesMap; }
From source file:uk.org.openeyes.oink.itest.karaf.OinkKarafITSupport.java
public static Properties getPropertiesBySystemProperty(String systemProperty) throws IOException { File f = getPropertyFileBySystemProperty(systemProperty); if (!f.exists()) { throw new FileNotFoundException("No file found at " + f.getAbsolutePath() + " for system property " + systemProperty + " is it set correctly?"); }/*from w w w . j a v a 2 s. c o m*/ FileInputStream fis = new FileInputStream(f); Properties p = new Properties(); p.load(fis); fis.close(); return p; }
From source file:com.geekcap.javaworld.sparkexample.proxy.CustomClientBuilder.java
private static String loadVersion() { String userAgent = "Hosebird-Client"; try {/*from w w w . j a v a 2 s .c o m*/ InputStream stream = ClientBuilder.class.getClassLoader().getResourceAsStream("build.properties"); try { Properties prop = new Properties(); prop.load(stream); String version = prop.getProperty("version"); userAgent += " " + version; } finally { stream.close(); } } catch (IOException ex) { // ignore } return userAgent; }
From source file:com.vmware.identity.openidconnect.client.GSSTestUtils.java
private static void getProperties() throws IOException { Properties properties = new Properties(); properties.load(OIDCClientGssIT.class.getClassLoader().getResourceAsStream("resources/config.properties")); String adDomain = properties.getProperty("ad.domain"); String adSpn = properties.getProperty("ad.spn"); String adUsername = properties.getProperty("ad.admin.user"); String adPassword = properties.getProperty("ad.admin.password"); spn = adSpn;//from ww w .j a va2s . c om principal = new PrincipalId(adUsername, adDomain); password = adPassword.toCharArray(); }