I tried a lot, but was unable to find a solution.
|
|--src/main/resouces
|
|-updatePropertiesFile.java
|-xyz_en_US.properties
|-xyz_e
This code iterates over all files in a given directory and opens each .properties
file. It then applies the changed values and stores the file again.
public void changePropertyFilesInFolder(File folder) {
for(File file : folder.listFiles()) {
if(file.isRegularFile() && file.getName().endsWith(".properties")) {
Properties prop = new Properties();
FileInputStream instream = new FileInputStream(file);
prop.load(instream);
instream.close();
prop.setProperty("foo", "bar"); // change whatever you want here
FileOutputStream outstream = new FileOutputStream(file);
prop.store(outstream, "comments go here");
outstream.close();
}
}
}