public static void modifyFile(File file,Function<String,String> modifier) throws IOException {
  String content=new String(Files.toByteArray(file),StandardCharsets.UTF_8);
  String result=modifier.apply(content);
  Files.write(result.getBytes(StandardCharsets.UTF_8),file);
}

public static void modifyFile ( File file , Function < String , String > modifier ) throws IOException { String content = new String ( Files . toByteArray ( file ) , StandardCharsets . UTF_8 ) ; String result = modifier . apply ( content ) ; Files . write ( result . getBytes ( StandardCharsets . UTF_8 ) , file ) ; }
modifies the given file in place .
