StringUtils.split() returns an empty string?

1.5k views Asked by At

Can StringUtils.split function in java return an empty string for input other than an empty string ?

2

There are 2 answers

0
Kaidul On

According to Doc, NO. Only a null input string will return null.

There are three versions of StringUtils.split():

Splits the provided text into an array, using whitespace as the separator

public static String[] split(String str)

Splits the provided text into an array, separator specified. This is an alternative to using StringTokenizer.

public static String[] split(String str, char separatorChar)

Splits the provided text into an array, separators specified. This is an alternative to using StringTokenizer.

public static String[] split(String str, String separatorChars)
0
Panther On

No , it will not return empty String "" for non-empty String. i believe you are talking about string with zero length "" , not about null.