Java, Java8, Java21, Java17, Migration.
Transform Indent method is used to add an indentation to each line of a string. It returns a new String instance with the specified number of spaces added to the beginning of each line. String original = "Hello\nWorld"; String indented = original.indent(4); System.out.println(indented); // Output: