Handle the special case of splitting up an empty source string, which
should return an empty array rather than an array containing an empty string. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1778 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1186,6 +1186,11 @@ public class StringUtil
|
|||||||
*/
|
*/
|
||||||
public static String[] split (String source, String sep)
|
public static String[] split (String source, String sep)
|
||||||
{
|
{
|
||||||
|
// handle the special case of a zero-component source
|
||||||
|
if (source.matches("\\s*")) {
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
int tcount = 0, tpos = -1, tstart = 0;
|
int tcount = 0, tpos = -1, tstart = 0;
|
||||||
|
|
||||||
// count up the number of tokens
|
// count up the number of tokens
|
||||||
|
|||||||
Reference in New Issue
Block a user