From 9c81cbfaaee8569fff499f44c5018b4d9c4415c7 Mon Sep 17 00:00:00 2001 From: andrzej Date: Wed, 1 Feb 2006 23:18:18 +0000 Subject: [PATCH] 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 --- src/java/com/samskivert/util/StringUtil.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/java/com/samskivert/util/StringUtil.java b/src/java/com/samskivert/util/StringUtil.java index dfcf98f4..dc4dcf1b 100644 --- a/src/java/com/samskivert/util/StringUtil.java +++ b/src/java/com/samskivert/util/StringUtil.java @@ -1186,6 +1186,11 @@ public class StringUtil */ 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; // count up the number of tokens