Replace text inline in a file
Replace text inline within a file.
Javadoc available at https://www.javatapas.com/docs/javatapas/io/ReplaceTextWithinFile.html
public static void replaceTextWithinFile(String inputFile, String oldText, String newText) throws IOException {
Path path = Paths.get(inputFile);
Charset charset = StandardCharsets.UTF_8;
String content = new String(Files.readAllBytes(path), charset);
content = content.replaceAll(oldText, newText);
Files.write(path, content.getBytes(charset));
}