How to convert String object to Boolean object?
public static boolean stringToBool(String s) {
s = s.toLowerCase();
Set trueSet = new HashSet(Arrays.asList("1", "true", "yes"));
Set falseSet = new HashSet(Arrays.asList("0", "false", "no"));
if (trueSet.contains(s))
return true;
if (falseSet.contains(s))
return false;
throw new IllegalArgumentException(s + " is not a boolean.");
}
My way to convert string to boolean.