Java Utililty Methods String Indent Format

List of utility methods to do String Indent Format

Description

The list of methods to do String Indent Format are organized into topic(s).

Method

Stringindent()
indent
String partial = "";
for (int i = 0; i < loggingIndentation; i++)
    partial = partial + "  ";
return partial;
voidindent(char thr, int level)
indent
System.out.print(thr + " ");
for (int i = 0; i < level; i++)
    System.out.print(" ");
StringBuilderindent(CharSequence input)
Indent a String.
return indent(input, "    ", 1, 1);
voidindent(final int depth, final int indentWidth, final StringBuilder buf)
Indent (depth * indentWidth) spaces.
final int maxIndent = INDENT_LEVELS.length - 1;
for (int d = depth * indentWidth; d > 0;) {
    final int n = Math.min(d, maxIndent);
    buf.append(INDENT_LEVELS[n]);
    d -= n;
voidindent(final int i, StringBuffer b)
indent
if (i > SPACES.length()) {
    b.append(SPACES);
    indent(i - SPACES.length(), b);
} else {
    b.append(SPACES.substring(0, i));
Stringindent(final int indent)
Creates a string with the specified level of indentation
final StringBuilder builder = new StringBuilder();
for (int i = 0; i < indent; i++) {
    builder.append(INDENT);
return builder.toString();
Stringindent(final int indents)
indent
return indent(indents, 4);
Stringindent(final int size)
indent
String indent = "";
for (int i = 1; i <= size; i++) {
    indent += " ";
return indent;
Stringindent(final String s)
indent
if (s.isEmpty()) {
    return s;
return TAB + s.replaceAll("(\\r\\n|\\r|\\n)(.+)", "$1" + TAB + "$2");
Stringindent(final String string, final String separator)
indent
final String t1 = "T1[" + string.hashCode() + "]";
final String t2 = "T2[" + string.hashCode() + "]";
final String r1 = string.replace("\r\n", t1 + separator);
final String r2 = r1.replace("\n", t2 + separator);
final String r3 = r2.replace(t1, "\r\n");
return r3.replace(t2, "\n");