Java String Indent Format indented(String indenter, String s)

Here you can find the source of indented(String indenter, String s)

Description

This method doesn't honor consecutive \n's unless they're separated.

License

Open Source License

Parameter

Parameter Description
indenter a parameter
s a parameter

Declaration

public static String indented(String indenter, String s) 

Method Source Code

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

public class Main {
    /**//from  ww w  . ja  v  a2s .c  o m
     * This method doesn't honor consecutive \n's unless they're separated.
     * So, use "\n \n" instead of "\n\n" to get a blank line.
     * @param indenter
     * @param s
     * @return
     */
    public static String indented(String indenter, String s) {
        String[] sArr = s.split("\n");
        String result = "";
        for (String currLine : sArr) {
            result += indenter + currLine + "\n";
        }
        return result;
    }
}

Related

  1. indentation(int howMany)
  2. indentation(int numberOfIndent)
  3. indentationLevel(CharSequence c)
  4. indentationStringOfCursorLine(String text, int cursor)
  5. indentCode(String code, int indentLevel)
  6. indentHtmlSpaces(int count)
  7. indention(int level, int tabSize)
  8. indentLinesAfterNth(final int skip, final int indent, final String str)
  9. indentMultilineValue(String value, StringBuilder tableInfo, int[] columnWidths, boolean printNull)