Index: StringUtils.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v retrieving revision 1.32 diff -u -r1.32 StringUtils.java --- StringUtils.java 20 Jan 2003 22:15:13 -0000 1.32 +++ StringUtils.java 22 Jan 2003 18:22:10 -0000 @@ -120,6 +120,21 @@ } /** + *

Removes control characters, including whitespace, from both + * ends of this String. Returns null if the String is empty or if + * it's null.

+ * + * @see StringUtils#isEmpty(String) + * @see java.lang.String#trim() + * @param str the String to check + * @return the trimmed text (or null) + */ + public static String trimNull(String str) { + String ts = trim(str); + return (ts == null || ts.length() == 0 ? null : ts); + } + + /** *

Deletes all 'space' characters from a String.

* *

Spaces are defined as {' ', '\t', '\r', '\n', '\b'}