All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.qbicc.tests.snippets.ResourceLoading Maven / Gradle / Ivy

There is a newer version: 0.77.0
Show newest version
package org.qbicc.tests.snippets;

import java.io.IOException;
import java.util.Properties;

public class ResourceLoading {
    static final Properties p = loadProps("test.properties");

    public static void main(String[] args) {
        String first = p.getProperty("my.value.first");
        String second = p.getProperty("my.value.second");
        int sum = Integer.parseInt(first) + Integer.parseInt(second);
        if (sum == 11) {
            System.out.print("P");
        } else {
            System.out.print("F");
        }
    }

    static Properties loadProps(String name) {
        Properties prop = new Properties();
        try {
            prop.load(ResourceLoading.class.getClassLoader().getResourceAsStream(name));
        } catch (IOException e) {
        }
        return prop;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy