Example usage for java.util Properties load

List of usage examples for java.util Properties load

Introduction

In this page you can find the example usage for java.util Properties load.

Prototype

public synchronized void load(InputStream inStream) throws IOException 

Source Link

Document

Reads a property list (key and element pairs) from the input byte stream.

Usage

From source file:Main.java

public static void getParam(String filename) {
    Properties props = new Properties();
    File file = new File(filename);
    try {/* www.  j a va2 s. c om*/
        props.load(new FileInputStream(file));
        //         String value = props.getProperty(key);
        driver = props.getProperty("driver");
        url = props.getProperty("url");
        dbUser = props.getProperty("dbUser");
        dbPwd = props.getProperty("dbPwd");
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.eclipse.lyo.testsuite.server.trsutils.TestCore.java

protected static Properties getConfigPropertiesInstance() throws FileNotFoundException, IOException {
    Properties prop = new Properties();

    prop.load(new FileInputStream(CONFIG_PROPERTIES));

    return prop;// ww w  . j  a v a  2s.  c  o  m
}

From source file:com.redhat.poc.jdg.bankofchina.performance.TestCase52RemoteMultiThreads.java

public static String jdgProperty(String name) {
    Properties props = new Properties();
    try {//w  ww .ja v a2  s .  c om
        props.load(TestCase52RemoteMultiThreads.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE));
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
    return props.getProperty(name);
}

From source file:com.axiomine.largecollections.utilities.KryoUtils.java

public static void registerKryoClasses(Kryo kryo, String propFile) throws Exception {
    FileReader fReader = new FileReader(new File(propFile));
    Properties props = new Properties();
    props.load(fReader);
    Set ks = props.keySet();/*from  w w  w.j ava 2  s  . com*/
    for (Object k : ks) {
        Class c = Class.forName((String) k);
        Class s = Class.forName(props.getProperty((String) k));
        Serializer ss = (Serializer) s.newInstance();
        kryo.register(c, ss);
    }

}

From source file:com.google.demo.translate.Translator.java

private static void parseInputs() {
    Properties prop = new Properties();
    try {//w  ww.j a  v  a2s .  c  o m
        prop.load(Translator.class.getClassLoader().getResourceAsStream("languages.properties"));
        it = FileUtils.lineIterator(
                new File(Translator.class.getClassLoader().getResource("input.csv").getPath()), "UTF-8");
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    source = prop.getProperty("source");
    String targetsList = prop.getProperty("targets");

    targets = new ArrayList<>(Arrays.asList(targetsList.split(",")));

    String path = Translator.class.getClassLoader().getResource("").getPath() + "output.csv";
    output = Paths.get(path);
}

From source file:com.redhat.poc.jdg.bankofchina.function.TestCase412RemoteMultiThreads.java

public static String jdgProperty(String name) {
    Properties props = new Properties();
    try {//from  w  ww . jav  a  2  s  . co m
        props.load(TestCase412RemoteMultiThreads.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE));
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
    return props.getProperty(name);
}

From source file:com.redhat.poc.jdg.bankofchina.performance.TestCase51RemoteMultiThreads.java

public static String jdgProperty(String name) {
    Properties props = new Properties();
    try {//from   ww  w  . j  a va 2s. c  om
        props.load(TestCase51RemoteMultiThreads.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE));
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
    return props.getProperty(name);
}

From source file:com.redhat.poc.jdg.bankofchina.performance.TestCase531RemoteMultiThreads.java

public static String jdgProperty(String name) {
    Properties props = new Properties();
    try {/*from  w  w w . j a v  a 2 s.  c  o  m*/
        props.load(TestCase531RemoteMultiThreads.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE));
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
    return props.getProperty(name);
}

From source file:com.redhat.poc.jdg.bankofchina.performance.TestCase532RemoteMultiThreads.java

public static String jdgProperty(String name) {
    Properties props = new Properties();
    try {//  ww  w.  ja va  2s.com
        props.load(TestCase532RemoteMultiThreads.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE));
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
    return props.getProperty(name);
}

From source file:cpcc.core.utils.VersionUtils.java

/**
 * @param moduleName the module name/*w ww .  j a  v a 2  s  .co  m*/
 * @return the module name and module version.
 */
public static String getModuleVersion(String moduleName, String propertyFile) {
    try (InputStream stream = Thread.currentThread().getContextClassLoader()
            .getResourceAsStream(propertyFile)) {
        Properties props = new Properties();
        props.load(stream);
        String version = props.getProperty("module.version");

        if (StringUtils.isEmpty(version)) {
            throw new IllegalArgumentException(String.format(VERSION_NOT_SET, propertyFile));
        }

        if (version.startsWith("${")) {
            throw new IllegalArgumentException(String.format(RESOURCE_FILTERING_FAILED, propertyFile));
        }

        if (version.endsWith("SNAPSHOT")) {
            version += '-' + System.currentTimeMillis();
        }

        return moduleName + '/' + version;
    } catch (IOException e) {
        throw new IllegalArgumentException(String.format(RESOURCE_NOT_FOUND, propertyFile));
    }
}