Java String Indent Format indent(String message, int indent)

Here you can find the source of indent(String message, int indent)

Description

Method which adds a specified amount of tabs to the message string.

License

Open Source License

Parameter

Parameter Description
message of type String: the message which will have tabs placed in front of it.
indent of type int: the number of tabs to be placed in front of the message.

Return

of type String: the original message with appended tabs to the front of it.

Declaration

public static String indent(String message, int indent) 

Method Source Code

//package com.java2s;
/*//from w ww .j  ava  2s .c om
 * The MIT License (MIT)
 *
 * Copyright (c) 2016 Goran Sarenkapa (JordanGS), and a number of other of contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

public class Main {
    /**
     * Method which adds a specified amount of tabs to the message string.
     * 
     * @param message
     *            of type String: the message which will have tabs placed in front of it.
     * @param indent
     *            of type int: the number of tabs to be placed in front of the message.
     * @return of type String: the original message with appended tabs to the front of it.
     */
    public static String indent(String message, int indent) {
        String temp = "";
        for (int i = 0; i < indent; i++)
            temp = temp + "\t";
        return temp + message;
    }
}

Related

  1. indent(int tabCount)
  2. indent(String in)
  3. indent(String in)
  4. indent(String input, int depth, int start)
  5. indent(String lines, String indentation)
  6. indent(String msg, int size)
  7. indent(String original, int spaces)
  8. indent(String s)
  9. indent(String s)