Java examples for java.lang:String Format
Indents every line of the String by 1 tab.
//package com.java2s; public class Main { public static void main(String[] argv) { String str = "java2s.com"; System.out.println(indent(str)); }// w ww .ja v a2 s . c om /** * Indents every line of the String by 1 tab. * * @param str * The string to indent * @return The indented string */ public static String indent(String str) { String[] lines = str.split("\\n"); String newStr = ""; for (String line : lines) { newStr += "\t" + line + "\n"; } return newStr; } }