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:com.kurento.test.base.BaseArquillianTst.java

@Deployment
public static WebArchive createDeployment() throws IOException {
    InputStream inputStream = new FileInputStream("target/test-classes/test.properties");
    Properties properties = new Properties();
    properties.load(inputStream);
    WebArchive war = ShrinkWrap.create(ZipImporter.class, "kmf-content-api-test.war")
            .importFrom(new File("target/" + properties.getProperty("project.artifactId") + "-"
                    + properties.getProperty("project.version") + ".war"))
            .as(WebArchive.class).addPackages(true, "com.kurento");

    return war;//from   w ww  . ja  v a 2s .  c  om
}

From source file:com.sonar.runner.it.ScannerTestCase.java

private static Version artifactVersion() {
    if (artifactVersion == null) {
        String scannerVersion = System.getProperty("scanner.version");
        if (StringUtils.isNotBlank(scannerVersion)) {
            LOG.info("Use provided Scanner version: " + scannerVersion);
            artifactVersion = Version.create(scannerVersion);
        } else {//  ww w.j  a  v  a 2 s  . c  om
            try (FileInputStream fis = new FileInputStream(
                    new File("../target/maven-archiver/pom.properties"))) {
                Properties props = new Properties();
                props.load(fis);
                artifactVersion = Version.create(props.getProperty("version"));
                return artifactVersion;
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }
    }
    return artifactVersion;
}

From source file:Main.java

public static Connection connectToDatabase(String propertiesFileName) throws Exception {
    Properties dbProps = new Properties();
    Properties dumpProps = new Properties();
    dbProps.load(new FileInputStream(propertiesFileName));
    dumpProps.load(new FileInputStream(propertiesFileName));
    System.out.println("Database Properties");
    dumpProps.remove("password");
    dumpProps.list(System.out);// w  w  w. j  av a  2 s .co  m
    System.out.println("Loading Driver");
    Class.forName(dbProps.getProperty("dbDriver"));

    System.out.println("Connecting to Database...");
    Connection con = DriverManager.getConnection(dbProps.getProperty("dbURL"), dbProps);
    System.out.println("Connected");
    return con;
}

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

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

From source file:com.parasoft.xtest.reports.jenkins.internal.rules.JenkinsRuleDocumentationProvider.java

private static Properties loadLocalSettings(File file) {
    InputStream input = null;/*from   w w  w. j a v  a 2 s  .  c  om*/
    try {
        input = new FileInputStream(file);
        Properties properties = new Properties();
        properties.load(input);
        return properties;
    } catch (FileNotFoundException e) {
        Logger.getLogger().warn("Localsettings file not found", e); //$NON-NLS-1$
    } catch (IOException e) {
        Logger.getLogger().warnTrace(e);
    } finally {
        IOUtils.closeQuietly(input);
    }
    return new Properties();
}

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

public static String jdgProperty(String name) {
    Properties props = new Properties();
    try {// w  w  w .ja va  2s .com
        props.load(TestCase411RemoteMultiThreads.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 resourceName the name of the resource to load for the version property.
 * @return the estimated version.//from   ww w.j ava  2 s  . com
 */
public static String getVersion(String resourceName) {
    InputStream propStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);

    if (propStream == null) {
        return UNKNOWN_VERSION;
    }

    try {
        Properties props = new Properties();
        props.load(propStream);
        return props.getProperty(PROP_APPLICATION_VERSION, UNKNOWN_VERSION);
    } catch (IOException e) {
        return UNKNOWN_VERSION;
    }
}

From source file:net.padaf.preflight.IsartorTargetFileInformation.java

public static List<IsartorTargetFileInformation> loadConfiguration(File root) throws Exception {
    // load config
    InputStream expected = IsartorTargetFileInformation.class.getResourceAsStream("/expected_errors.txt");
    Properties props = new Properties();
    props.load(expected);
    // list files
    List<IsartorTargetFileInformation> result = new ArrayList<IsartorTargetFileInformation>();
    if (root.isDirectory()) {
        Collection<?> col = FileUtils.listFiles(root, new String[] { "pdf" }, true);
        for (Object o : col) {
            File file = (File) o;
            IsartorTargetFileInformation info = getInformation(file, props);
            if (info == null) {
                continue;
            }// w  ww . jav  a2 s . c o  m
            result.add(info);
        }
    } else if (root.isFile()) {
        result.add(getInformation(root, props));
    }
    return result;
}

From source file:net.jcreate.e3.templateEngine.webmacro.WebMacroHelper.java

public static Properties getDefaultProperties() throws InitWebMacroEngineException {
    InputStream is = WebMacroHelper.class.getResourceAsStream("WebMacro.properties");
    Properties props = new Properties();
    try {/*from w ww .j  av  a2  s  .  co m*/
        props.load(is);
    } catch (IOException e) {
        final String MSG = "!" + e.getMessage();
        if (log.isErrorEnabled()) {
            log.error(MSG, e);
        }
        throw new InitWebMacroEngineException(MSG, e);
    }
    return props;
}

From source file:Main.java

public static Properties loadConfig(Context context, String file) {
    Properties properties = new Properties();
    try {//  ww w .  j a v a  2 s .  c o m
        FileInputStream s = new FileInputStream(file);
        properties.load(s);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return properties;
}