2005/08/15

Smartly load your properties

Link

Example
Assume I have a property file which named config, and this file locate at src/albert.
This file contains two values:
name=albert
email=junyuo@gmail.com

Then you can utilize this approach to read this property file

InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("albert/config.properties");
PropertyResourceBundle rb = new PropertyResourceBundle(is);
System.out.println("name="+rb.getString("name"));
System.out.println("email="+rb.getString("email"));

No comments: