Which Java library lets me initialize an object's properties from a properties file?
Posted
by Kjetil Ødegaard
on Stack Overflow
See other posts from Stack Overflow
or by Kjetil Ødegaard
Published on 2010-05-21T07:32:05Z
Indexed on
2010/05/21
8:00 UTC
Read the original article
Hit count: 198
java
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?
© Stack Overflow or respective owner