Here you can find the source of toBoolean(String value)
public static boolean toBoolean(String value)
//package com.java2s; /**/*from w ww .j a v a 2 s . c om*/ * * Copyright (c) 2015 Fannie Mae, All rights reserved. * This program and the accompany materials are made available under * the terms of the Fannie Mae Open Source Licensing Project available * at https://github.com/FannieMaeOpenSource/ezPie/wiki/License * * ezPIE? is a registered trademark of Fannie Mae * */ public class Main { public static boolean toBoolean(String value) { return toBoolean(value, false); } public static boolean toBoolean(String value, Boolean defaultValue) { if (isNullOrEmpty(value)) return defaultValue; else if ("|true|t|y|1|on|yes|".indexOf("|" + value.trim().toLowerCase() + "|") > -1) return true; else if ("|false|f|n|0|off|no|".indexOf("|" + value.trim().toLowerCase() + "|") > -1) return false; return defaultValue; } public static boolean isNullOrEmpty(String value) { return (value == null) || value.isEmpty(); } }