Friday, September 24, 2010

Escaping Strings using org.apache.commons.lang.StringEscapeUtils

You often run into the problem of escaping Strings from certain characters that need to be encoded as entitys in the format you use.

Apache has a great library in its commons-lang repository willing to do all that nasty and time-consuming work for you. Simply add this dependency to your pom.xml and start using it:

The class to go for when wanting to escape Strings is StringEscapeUtils.

Escaping html strings is as easy as

Have fun!

No comments:

Post a Comment

Please leave your comment here.