diff --git a/src/main/java/org/openrewrite/java/template/processor/TemplateProcessor.java b/src/main/java/org/openrewrite/java/template/processor/TemplateProcessor.java index 1257ac41..905ac2f5 100644 --- a/src/main/java/org/openrewrite/java/template/processor/TemplateProcessor.java +++ b/src/main/java/org/openrewrite/java/template/processor/TemplateProcessor.java @@ -183,8 +183,10 @@ public void visitApply(JCTree.JCMethodInvocation tree) { } private String indent(String code, int width) { - String indent = "$1" + String.join("", Collections.nCopies(width, " ")); - return code.replaceAll("(?m)(\\R)", indent); + char[] indent = new char[width]; + Arrays.fill(indent, ' '); + String replacement = "$1" + new String(indent); + return code.replaceAll("(?m)(\\R)", replacement); } }.scan(cu); }