I have a list of key/value pairs of configuration values I want to store as Java property files, and later load and iterate through.
Questions:
There are many ways to create and read properties
files:
.properties
extension however you can choose your own.java.util
package => Properties
, ListResourceBundle
, ResourceBundle
classes.Properties
or java.lang.System
class.ResourceBundle
class:
ResourceBundle rb = ResourceBundle.getBundle("prop"); // prop.properties
System.out.println(rb.getString("key"));
Properties
class:
Properties ps = new Properties();
ps.Load(new java.io.FileInputStream("my.properties"));