Java String Indent Format indent(int level)

Here you can find the source of indent(int level)

Description

Accessor for the character sequence that indicates an indent.

License

Open Source License

Parameter

Parameter Description
The indent level

Declaration

public static String indent(int level) 

Method Source Code

//package com.java2s;
/* *******************************************************************************************************
Copyright (c) 2015 EXILANT Technologies Private Limited
    /*from   ww  w  .j a  v a 2s.  c  o  m*/
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 {
    /**
     * Accessor for the character sequence that indicates an indent. Used for
     * code formatting during auto-generation
     * 
     * @param The
     *            indent level
     */
    public static String indent(int level) {
        StringBuffer sb = new StringBuffer();
        int i = level;
        while (i > 0) {
            sb.append('\t');
            i--;
        }
        return sb.toString();
    }
}

Related

  1. indent(int indent)
  2. indent(int indent)
  3. indent(int indent, int tab, String string)
  4. indent(int indent, StringBuffer sb)
  5. indent(int indentLevel)
  6. indent(int level)
  7. indent(int level)
  8. indent(int level)
  9. indent(int n)