I have this object:
public class TheObjectToInstantiate{
public String Name;
public String Surname;
public TheObjectToInstantiate(){
}
}
I want to instantiate an array of TheObjectToInstantiate[] with configuration file:
TheObjectToInstantiate1.Name="Pippo"
TheObjectToInstantiate1.Surname="PippoSurname"
TheObjectToInstantiate2.Name="Pluto"
TheObjectToInstantiate2.Surname="PlutoSurname"
I've tried with
public ConfigReader(){
Properties prop = new Properties();
InputStream input = null;
try {
input = new FileInputStream("configuration.prop");
prop.load(input);
Enumeration<?> e = prop.propertyNames();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
String value = prop.getProperty(key);
......
}
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
scanning all properties and instatiate object manually.
There are ways or open source wrapper to do this without manually compare all properties? Thanks