diff --git a/src/java/org/apache/commons/lang/CharSetUtils.java b/src/java/org/apache/commons/lang/CharSetUtils.java index c50b61a3a..71dbbcc80 100644 --- a/src/java/org/apache/commons/lang/CharSetUtils.java +++ b/src/java/org/apache/commons/lang/CharSetUtils.java @@ -63,7 +63,7 @@ import java.util.LinkedList; * * @author Henri Yandell * @author Stephen Colebourne - * @version $Id: CharSetUtils.java,v 1.1 2002/07/19 03:35:54 bayard Exp $ + * @version $Id: CharSetUtils.java,v 1.2 2002/07/21 20:14:14 bayard Exp $ */ public class CharSetUtils { @@ -159,6 +159,15 @@ public class CharSetUtils { return count; } + /** + * Deletes all whitespace from a String. + * + * @param str String target to delete whitespace from + */ + public static String deleteWhitespace(String str) { + return delete(str, " \t\r\n\b" ); + } + /** * Takes an argument in set-syntax, see evaluateSet, * and deletes any of characters present in the specified string. diff --git a/src/test/org/apache/commons/lang/CharSetUtilsTest.java b/src/test/org/apache/commons/lang/CharSetUtilsTest.java index d02110b7e..667ce73b3 100644 --- a/src/test/org/apache/commons/lang/CharSetUtilsTest.java +++ b/src/test/org/apache/commons/lang/CharSetUtilsTest.java @@ -65,7 +65,7 @@ import junit.textui.TestRunner; * * @author Henri Yandell * @author Ringo De Smet - * @version $Id: CharSetUtilsTest.java,v 1.1 2002/07/19 03:35:54 bayard Exp $ + * @version $Id: CharSetUtilsTest.java,v 1.2 2002/07/21 20:14:14 bayard Exp $ */ public class CharSetUtilsTest extends TestCase { @@ -135,6 +135,8 @@ public class CharSetUtilsTest extends TestCase "", CharSetUtils.delete("hello", new String[] {"a-z"})); assertEquals("delete(String,String[]) failed", "heo", CharSetUtils.delete("hello", new String[] {"l"})); + assertEquals("deleteWhitespace(String) failed", + "test", CharSetUtils.deleteWhitespace("t \t\ne\rs\n\n \tt")); } }