is string Whitespace - Android java.lang

Android examples for java.lang:String Null or Empty

Description

is string Whitespace

Demo Code

public class Main{
    public static final String NEWLINE = "\n";
    public static final String ATAB = String.valueOf('\u0009');
    public static final String ASPACE = " ";
    public static boolean isWhitespace(String text) {
        //String ret = "";
        boolean ret = true;
        char chTemp;
        String strTemp;/*from   w w  w  .j  a va2 s . c o  m*/
        boolean boolA, boolB, boolC;
        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);
            boolC = strTemp.equals("\n");
            if (boolA || boolB || boolC)
                ;
            else
                return false;
        }
        //TestInfo.testWriteLn("Indent: " + ret);
        return ret;
    }

}

Related Tutorials