Here you can find the source of toBoolean(String input, boolean defaultValue)
public static boolean toBoolean(String input, boolean defaultValue)
//package com.java2s; //License from project: Apache License public class Main { public static boolean toBoolean(String input, boolean defaultValue) { if (input == null) { return defaultValue; }//from w w w .ja v a 2 s.c o m try { return Boolean.valueOf(input).booleanValue(); } catch (Exception e) { return defaultValue; } } }