Here you can find the source of indent(int i, String s)
public static String indent(int i, String s)
//package com.java2s; /*//from ww w . j av a2 s . co m (C) 2007 Stefan Reich (jazz@drjava.de) This source file is part of Project Prophecy. For up-to-date information, see http://www.drjava.de/prophecy This source file is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, version 2.1. */ public class Main { public static String indent(int i, String s) { String spaces = repeat(i, ' '); return spaces + s.replace("\n", "\n" + spaces); } private static String repeat(int len, char c) { char[] chars = new char[len]; for (int i = 0; i < len; i++) chars[i] = c; return new String(chars); } public static String replace(String pattern, String substitute, String s) { StringBuffer buf = new StringBuffer(); while (true) { int i = s.indexOf(pattern); if (i >= 0) { buf.append(s.substring(0, i)); buf.append(substitute); s = s.substring(i + pattern.length()); } else { buf.append(s); break; } } return buf.toString(); } }