Android String Indent getIndent(String text)

Here you can find the source of getIndent(String text)

Description

Get the whitespace that is the prefix of the given text

Declaration

public static String getIndent(String text) 

Method Source Code

//package com.java2s;

public class Main {
    public static final String ATAB = String.valueOf('\u0009');
    public static final String ASPACE = " ";

    /** Get the whitespace that is the prefix of the given text */
    public static String getIndent(String text) {
        String ret = "";
        char chTemp;
        String strTemp;//from  w w  w .ja  v  a  2 s.c  o m
        boolean boolA, boolB;
        for (int i = 0; i < text.length(); i++) {
            boolA = false;
            boolB = false;
            chTemp = text.charAt(i);
            strTemp = String.valueOf(chTemp);
            boolA = strTemp.equals(ASPACE);
            boolB = strTemp.equals(ATAB);
            if (boolA || boolB)
                ret += strTemp;
            else
                return ret;
        }
        //TODO: TestInfo.testWriteLn("Indent: " + ret);
        return ret;
    }
}

Related

  1. indent(int level)
  2. indent(int level, int spaces)
  3. appendIndentString(StringBuffer appendToMe, int level)
  4. getIndentStringWithLevel(int level)