Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static final Set<String> trueSet = new HashSet<String>(Arrays.asList("1", "true", "yes"));
- private static final Set<String> falseSet = new HashSet<String>(Arrays.asList("0", "false", "no"));
- public static boolean stringToBool(String s) {
- s = s.toLowerCase();
- if (trueSet.contains(s))
- return true;
- if (falseSet.contains(s))
- return false;
- throw new IllegalArgumentException(s + " is not a boolean.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement