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(int nSpaces)
For tree dumper.
return SPACES.substring(0, nSpaces);
Stringindent(int number)
indent
StringBuffer result = new StringBuffer();
for (int i = 0; i < number; i++) {
    result.append(SPACE);
return result.toString();
Stringindent(int numSpaces)
indent
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < numSpaces; ++i)
    buffer.append(" ");
return buffer.toString();
voidindent(int numSpaces)
indent
indentWith(spaces.substring(0, numSpaces));
Stringindent(int tabCount)
indent
String s = new String();
for (int i = 0; i < tabCount; ++i) {
    s = s + '\t';
return s;
Stringindent(String in)
indent
return indent(in, "\t");
Stringindent(String in)
indent
StringBuilder sb = new StringBuilder(in);
sb.insert(0, "  ");
for (int i = 0; i < sb.length(); i++) {
    char c = sb.charAt(i);
    if (c == '\n') {
        sb.insert(i + 1, "  ");
return sb.toString();
Stringindent(String input, int depth, int start)
Helper method used to indent text.
String[] text = stringToArray(input);
for (int i = start; i < text.length; i++) {
    text[i] = printNTimes(" ", depth) + text[i];
return arrayToString(text);
Stringindent(String lines, String indentation)
Prepends the String indentation to every line in String lines , including a possibly non-empty line following the final newline.
if (lines.length() == 0) {
    return lines;
final String newLine = "\n";
if (lines.endsWith(newLine)) {
    return indentation + (lines.substring(0, lines.length() - 1)).replace(newLine, newLine + indentation)
            + newLine;
return indentation + lines.replace(newLine, newLine + indentation);
Stringindent(String message, int indent)
Method which adds a specified amount of tabs to the message string.
String temp = "";
for (int i = 0; i < indent; i++)
    temp = temp + "\t";
return temp + message;