Java String Indent Format indentNextLines(String text, String indent)

Here you can find the source of indentNextLines(String text, String indent)

Description

indent Next Lines

License

Open Source License

Declaration

protected static String indentNextLines(String text, String indent) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    protected static String indentNextLines(String text, String indent) {
        String origText = new String(text);
        String ret = new String();
        String[] lines = text.split("\\n");
        for (int i = 0; i < lines.length; i++) {
            // last line and no final \n on orig text
            if (i == lines.length - 1 && !origText.endsWith("\n"))

                ret += indent + lines[i];
            else/*from   www .  ja  v  a 2s .  co  m*/
                ret += indent + lines[i] + "\n";
        }
        return ret;
    }
}

Related

  1. indented(String indenter, String s)
  2. indentHtmlSpaces(int count)
  3. indention(int level, int tabSize)
  4. indentLinesAfterNth(final int skip, final int indent, final String str)
  5. indentMultilineValue(String value, StringBuilder tableInfo, int[] columnWidths, boolean printNull)
  6. indentParagraph(String textBefore, String textToModify)
  7. indentRows(int level, String ss, String indentStr)
  8. indentStr(int level)
  9. indentString(final int indentSpaces)