-1
VaidAbhishek
  • 5,895
  • 7
  • 43
  • 59
  • intentional http://grepcode.com/file/repo1.maven.org/maven2/commons-lang/commons-lang/2.6/org/apache/commons/lang/StringUtils.java#2659 – goat Mar 29 '15 at 14:39
  • What would you expect from splitting by `""`? Internally, `""` and `null` are treated equal. `if (separator == null || EMPTY.equals(separator))` – AlexR Mar 29 '15 at 14:40

1 Answers1

1

You're right. There's a lack in the documentation. null and empty String separator will produce a split on whitespace.

Internally the code is doing this:

    if (separator == null || EMPTY.equals(separator)) {
        // Split on whitespace.
        return splitWorker(str, null, max, preserveAllTokens);
    }

So these two calls will produce the same result:

StringUtils.splitByWholeSeparator("ab de fg", null);

StringUtils.splitByWholeSeparator("ab de fg", "");
jfcorugedo
  • 9,793
  • 8
  • 39
  • 47