Which Java library lets me initialize an object's properties from a properties file?
- by Kjetil Ødegaard
Is there a Java library that lets you "deserialize" a properties file directly into an object instance?
Example: say you have a file called init.properties:
username=fisk
password=frosk
and a Java class with some properties:
class Connection {
private String username;
private String password;
public void setUsername(String username) {
this.username = username;
}
public void setPassword(String password) {
this.password = password;
}
}
I want to do this:
Connection c = MagicConfigurator.configure("init.properties", new Connection())
and have MagicConfigurator apply all the values from the properties file to the Connection instance.
Is there a library with a class like this?