Java Boolean From toBoolean(String value, boolean defaultValue)

Here you can find the source of toBoolean(String value, boolean defaultValue)

Description

convert the string to a boolean, returning the default value if null

License

Open Source License

Parameter

Parameter Description
value string value
defaultValue default value

Return

boolean

Declaration

static public boolean toBoolean(String value, boolean defaultValue) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*w w w . jav a2  s  . c  o m*/
     * convert the string to a boolean, returning the default value if null
     *
     * @param value string value
     * @param defaultValue default value
     *
     * @return boolean
     */
    static public boolean toBoolean(String value, boolean defaultValue) {
        if (value == null) {
            return defaultValue;
        }
        return Boolean.valueOf(value).booleanValue();
    }

    /**
     * convert the string to a boolean
     *
     * @param value string value
     *
     * @return boolean
     */
    static public boolean toBoolean(String value) {
        return Boolean.valueOf(value).booleanValue();
    }
}

Related

  1. toBoolean(String value)
  2. toBoolean(String value)
  3. toBoolean(String value, boolean _default)
  4. toBoolean(String value, boolean dEfault)
  5. toBoolean(String value, boolean defaultValue)
  6. toBoolean(String value, boolean defaultValue)
  7. toBoolean(String value, boolean defaultValue)
  8. toBoolean(StringBuilder value)
  9. toBooleanA(byte[] data)