One option with Java Properties
Other wise, alternative options would be, you can use IO Api and manually update it like below:
1) Create a map, which has key and value that you want to going to update in file.
HashMap<String, String> replaceValesMap = new HashMap<String, String>();
2) Read a file from path as it gives you real path i.e. war/fileName.layout
String filepath = getServletContext().getRealPath("fileName.layout");
3) Create a method, which read file and replace value, return modified strings.
public static String getreportPdfString(HashMap<String, String> replaceValesMap,String fileppath){
String generatedString = "";
File file = new File(fileppath);
StringBuffer strContent = new StringBuffer("");
FileInputStream fin = null;
try {
fin = new FileInputStream(file);
int ch;
while ((ch = fin.read()) != -1)
strContent.append((char) ch);
fin.close();
} catch (Exception e) {
System.out.println(e);
}
String fileString= strContent.toString();
for (Map.Entry<String, String> entry : replaceValesMap.entrySet()) {
fileString = StringUtils.replace(fileString, entry.getKey(),entry.getValue());
}
return fileString;
}
4) Finally write into file:
try (PrintStream out = new PrintStream(new FileOutputStream("fileName.layout"))) {
out.print(text);
}