Java Boolean From toBoolean(String str)

Here you can find the source of toBoolean(String str)

Description

to Boolean

License

Apache License

Declaration

public static Boolean toBoolean(String str) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static Boolean toBoolean(String str) {
        if (isTrue(str))
            return true;
        if (isFalse(str))
            return false;
        return null;
    }/*from   w ww .j  a v a 2  s. c om*/

    public static boolean isTrue(String str) {
        return "1".equals(str) || "true".equalsIgnoreCase(str) || "yes".equalsIgnoreCase(str)
                || "on".equalsIgnoreCase(str);
    }

    public static boolean isFalse(String str) {
        return "0".equals(str) || "false".equalsIgnoreCase(str) || "no".equalsIgnoreCase(str)
                || "off".equalsIgnoreCase(str);
    }
}

Related

  1. toBoolean(String inString)
  2. toBoolean(String propertyValue)
  3. toBoolean(String s)
  4. toBoolean(String s)
  5. toBoolean(String str)
  6. toBoolean(String str)
  7. toBoolean(String str)
  8. toBoolean(String string)
  9. toBoolean(String string)