Java Boolean From toBoolean(final String s)

Here you can find the source of toBoolean(final String s)

Description

Convert a string into a boolean primitive (i.e.

License

BSD License

Parameter

Parameter Description
s A boolean string equivalent

Return

A boolean value

Declaration

public static boolean toBoolean(final String s) 

Method Source Code

//package com.java2s;
/*L/*from  w  ww. ja v a 2s  .c  o  m*/
 *  Copyright RTI International
 *
 *  Distributed under the OSI-approved BSD 3-Clause License.
 *  See http://ncip.github.com/webgenome/LICENSE.txt for details.
 */

public class Main {
    /**
     * Convert a string into a boolean primitive
     * (i.e. {"true","yes"} -> true).
     * @param s A boolean string equivalent
     * @return A boolean value
     */
    public static boolean toBoolean(final String s) {
        String temp = s.toUpperCase();
        return "TRUE".equals(temp) || "YES".equals(temp) || "ON".equals(temp);
    }
}

Related

  1. toBoolean(final Object obj, final boolean defaultValue)
  2. toBoolean(final Object value)
  3. toBoolean(final Object value, final boolean defaultValue)
  4. toBoolean(final Object valueRep)
  5. toBoolean(final String booleanString, final boolean defaultValue)
  6. toBoolean(final String s)
  7. toBoolean(final String source)
  8. toBoolean(final String string)
  9. toBoolean(final String strTransparent)