Here you can find the source of indent(final StringBuilder aSb, final String aIndentString)
Parameter | Description |
---|---|
aSb | [in/out] the string to modify |
aIndentString | [in] the requested string to append |
public static void indent(final StringBuilder aSb, final String aIndentString)
//package com.java2s; /****************************************************************************** * Copyright (c) 2000-2018 Ericsson Telecom AB * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html * * Contributors:/* w w w . j a v a 2s. c o m*/ * Balasko, Jeno * Lovassy, Arpad * ******************************************************************************/ public class Main { /** * Changes the indentation of the string, a requested string is appended after every EOFs in the string. * @param aSb [in/out] the string to modify * @param aIndentString [in] the requested string to append */ public static void indent(final StringBuilder aSb, final String aIndentString) { replaceString(aSb, "\n", "\n" + aIndentString); } /** * Replaces all the occurrences of a given string * @param aSb [in/out] the string to modify * @param aFrom [in] the string to replace * @param aTo [in] the replacement string */ public static void replaceString(final StringBuilder aSb, final String aFrom, final String aTo) { int index = aSb.indexOf(aFrom); while (index != -1) { aSb.replace(index, index + aFrom.length(), aTo); index += aTo.length(); // Move to the end of the replacement index = aSb.indexOf(aFrom, index); } } }