Modifies the given file in place.
(File file, Function<String, String> modifier)
| 257 | |
| 258 | /** Modifies the given file in place. */ |
| 259 | public static void modifyFile(File file, Function<String, String> modifier) throws IOException { |
| 260 | String content = new String(Files.toByteArray(file), StandardCharsets.UTF_8); |
| 261 | String result = modifier.apply(content); |
| 262 | Files.write(result.getBytes(StandardCharsets.UTF_8), file); |
| 263 | } |
| 264 | |
| 265 | /** Deletes the given file or directory if it exists, then creates a fresh directory in its place. */ |
| 266 | public static void cleanDir(File dirToRemove) throws IOException { |
no test coverage detected