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(String msg, int size)
indent
int msgLength;
if (msg == null) {
    msgLength = 0;
} else {
    msgLength = msg.length();
int indentLength = size - msgLength;
String indent = "";
...
Stringindent(String original, int spaces)
indent
String indent = stringOfChar(' ', spaces);
String indented = indent + original;
indented = replaceAll(indented, "\r\n", "<<<<.CRLF.>>>>");
indented = replaceAll(indented, "\r", "<<<<.CR.>>>>");
indented = replaceAll(indented, "\n", "<<<<.LF.>>>>");
indented = replaceAll(indented, "<<<<.CRLF.>>>>", "\r\n" + indent);
indented = replaceAll(indented, "<<<<.CR.>>>>", "\r" + indent);
indented = replaceAll(indented, "<<<<.LF.>>>>", "\n" + indent);
...
Stringindent(String s)
indent
return s + indentation;
Stringindent(String s)
Indents a string with 4 spaces.
return indent(s, 4, true);
Stringindent(String s)
indent
return "    " + s.trim().replace("\n", "\n    ");
Stringindent(String s)
indent
return new StringBuilder(s.replaceAll("\n", "\n\t")).insert(0, "\t").toString();
Stringindent(String s, int numBlanks)
Inserts blanks at the start of the string.
StringBuilder result;
int i;
result = new StringBuilder();
for (i = 0; i < numBlanks; i++)
    result.append(" ");
result.append(s);
return result.toString();
Stringindent(String str)
Indents every line of the String by 1 tab.
String[] lines = str.split("\\n");
String newStr = "";
for (String line : lines) {
    newStr += "\t" + line + "\n";
return newStr;
Stringindent(String str, String indent)
indent
if (isNullOrEmpty(str))
    return str;
return indent + str.replaceAll("\n", "\n" + indent);
Stringindent(String string)
Indents the given string with one tab.
return "\t" + string.replace("\n", "\n\t");