public static void writeToFileAndUpdateMTime(Path file, String contents) throws IOException {
if(!file.toFile().exists()) {
writeStringToFile(file, contents);
return;
}
FileTime lastModifiedTime = Files.getLastModifiedTime(file);
writeStringToFile(file, contents);
// Make sure last modified time is different from before
Files.setLastModifiedTime(file, FileTime.fromMillis(lastModifiedTime.toMillis() - 1_000));
}