diff --git a/NOTICE.txt b/NOTICE.txt
index 032e12776..ad434a448 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -3,3 +3,5 @@ Copyright 2001-2010 The Apache Software Foundation
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
+
+This product includes software from the Spring Framework.
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java
index 67a566e33..a480c131f 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -1347,6 +1347,28 @@ public class StringUtils {
return false;
}
+ /**
+ * Check whether the given String contains any whitespace characters.
+ * @param str the String to check (may be null
)
+ * @return true
if the String is not empty and
+ * contains at least 1 whitespace character
+ * @see java.lang.Character#isWhitespace
+ * @since 3.0
+ */
+ // From org.springframework.util.StringUtils, under Apache License 2.0
+ public static boolean containsWhitespace(String str) {
+ if (isEmpty(str)) {
+ return false;
+ }
+ int strLen = str.length();
+ for (int i = 0; i < strLen; i++) {
+ if (Character.isWhitespace(str.charAt(i))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
// IndexOfAny chars
//-----------------------------------------------------------------------
/**
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
index 84f5cbaa0..a65749869 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
@@ -431,6 +431,16 @@ public class StringUtilsEqualsIndexOfTest extends TestCase {
assertEquals(true, StringUtils.containsOnly(str3, chars3));
}
+ public void testContainsWhitespace() {
+ assertFalse( StringUtils.containsWhitespace("") );
+ assertTrue( StringUtils.containsWhitespace(" ") );
+ assertFalse( StringUtils.containsWhitespace("a") );
+ assertTrue( StringUtils.containsWhitespace("a ") );
+ assertTrue( StringUtils.containsWhitespace(" a") );
+ assertTrue( StringUtils.containsWhitespace("a\t") );
+ assertTrue( StringUtils.containsWhitespace("\n") );
+ }
+
public void testEquals() {
assertEquals(true, StringUtils.equals(null, null));
assertEquals(true, StringUtils.equals(FOO, FOO));