load Properties File - Java java.util

Java examples for java.util:Properties File

Description

load Properties File

Demo Code


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

public class Main{
    public static void main(String[] argv) throws Exception{
        String file = "java2s.com";
        System.out.println(loadPropertiesFile(file));
    }/*ww  w . java 2  s  . co  m*/
    private static Properties loadPropertiesFile(String file) {
        Properties p = new Properties();
        try {
            InputStream is = Factories.class.getResourceAsStream(file);

            p.load(is);

            is.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return p;
    }
}

Related Tutorials