public final static String[] split(String source, String delimiter, boolean ignoreBlank)
{
if (org.apache.commons.lang.StringUtils.isBlank(source))
{
return null;
}
if (org.apache.commons.lang.StringUtils.isEmpty(delimiter))
{
return new String[]{source};
}
int delimLength = delimiter.length();
List<String> delimList = new ArrayList<String>();
int lastOffset = 0;
int offset = source.indexOf(delimiter);
while (offset >= 0)
{
String dest = source.substring(lastOffset, offset);
if (!ignoreBlank || !org.apache.commons.lang.StringUtils.isBlank(dest))
{
delimList.add(dest);
}
lastOffset = offset + delimLength;
offset = source.indexOf(delimiter, lastOffset);
}
if (lastOffset <= source.length())
{
String dest = source.substring(lastOffset);
if (!ignoreBlank || !org.apache.commons.lang.StringUtils.isBlank(dest))
{
delimList.add(dest);
}
}
return delimList.toArray(new String[delimList.size()]);
}