private static void addImports ( Path file , boolean addImports ) throws IOException { Charset charset = StandardCharsets . UTF_8 ; String content = new String ( Files . readAllBytes ( file ) , charset ) ; if ( addImports ) { content = content . replaceAll ( "_imports_" , "import \"strconv\"\n\n" ) ; } else { content = content . replaceAll ( "_imports_" , "" ) ; } Files . write ( file , content . getBytes ( charset ) ) ; }
or removes it in case there isn t any packages to import