Wednesday January 22, 2003
Commons Lang: StringUtils
My new favorite method is the equals method on Commons Lang's
StringUtils class. It takes the check for null out of your logic and can help you create cleaner code. Before using it you might have to write something like this:
if (request.getParameter("checkbox") != null
&& (request.getParameter("checkbox").equals("true"))) {
With StringUtils.equals(String, String), you get a little less coding:
if (StringUtils.equals(request.getParameter("checkbox"), "true")) {
If you're using Struts or some other library that already depends on commons-lang, why wouldn't you use it? Possibly performance reasons, but I doubt it causes much of a hit.
Posted in Java
at Jan 22 2003, 06:05:51 AM MST
4 Comments
Search This Site
Recent Entries
- Wine Tasting in Napa Valley
- How to build a Shot-Ski
- Bus Project Update
- Farewell to the 2011-2012 Ski Season
- Cruising around the Western Caribbean
- Spring Break!
- A Spectacular Trip to Stockholm and Madrid
- Comparing Web Frameworks and HTML5 with Play Scala at Jfokus 2012
- Play Framework 2.0 with Peter Hilton at Jfokus
- Secure JSON Services with Play Scala and SecureSocial
Posted by James Chochlinski on January 22, 2003 at 07:17 AM MST #
Posted by Martin van den Bemt on January 22, 2003 at 09:03 AM MST #
Posted by Chris Winters on January 22, 2003 at 09:58 AM MST #
Posted by Danman on January 22, 2003 at 10:54 AM MST #