users@glassfish.java.net

Re: Properties-File

From: <glassfish_at_javadesktop.org>
Date: Tue, 09 Sep 2008 10:49:00 PDT

I found the following for populating a Properties object from a file which is in the CLASSPATH


InputStream inputStream = null;
try {
        String filename = "xyz_properties";
        inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
        if(inputStream == null) {
                Exception e = new Exception("Trouble finding " + filename + " is it in the CLASSPATH ?");
                throw(e);
        }
        properties = new Properties();
        properties.load(inputStream);
        inputStream.close();
}
[Message sent by forum member 'vincewebb' (vincewebb)]

http://forums.java.net/jive/thread.jspa?messageID=298140