Parsing "true" / "false" in Java -



Parsing "true" / "false" in Java -

what's utility method parses boolean string properly? mean

"true" => true "false" => false "foo" => error

the parse methods in java.lang.boolean dodgy - don't distinguish "false" "foo". else in java libraries (or guava, or commons lang) properly?

yes it's couple lines, rather not write any line shouldn't have to. :-)

check out boolean utils form apache commons :

boolean utils api

converts string boolean throwing exception if no match found.

null returned if there no match.

booleanutils.toboolean("true", "true", "false") = true booleanutils.toboolean("false", "true", "false") = false

java parsing text-processing

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -