Can StringUtils.split function in java return an empty string for input other than an empty string ?
Asked
Active
Viewed 1,512 times
0
-
No. From Docs- "Returns: an array of parsed Strings, null if null String input" – Mahesh Jul 25 '14 at 10:53
-
as StringUtils.split returns null only for null input, you may be using it incorrectly. post your code that uses StringUtils.split – Pat Jul 25 '14 at 11:23
2 Answers
0
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)

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

Panther
- 3,312
- 9
- 27
- 50