Properties properties = new Properties();
//Getting and Setting Properties
String string = properties.getProperty("nome_chiave");
properties.setProperty("nome_chiave", "valore");
properties.setProperty("nome_chiave", "valore");
// Read properties file.
try {
properties.load(new FileInputStream("filename.properties"));
} catch (IOException e) {
}
try {
properties.load(new FileInputStream("filename.properties"));
} catch (IOException e) {
}
// Write properties file.
try {
properties.store(new FileOutputStream("filename.properties"), null);
} catch (IOException e) {
}
try {
properties.store(new FileOutputStream("filename.properties"), null);
} catch (IOException e) {
}
Importante: properties.store() deve essere eseguito "dopo" properties.setProperty()
Nessun commento:
Posta un commento