实现java1.4中的split()函数功能的代码- -
split()函数是分隔字符串的函数,在JDK1.4以后才有的.
在以前的版本里要用这个函数时,需要自己去写.
lotus r6中的JDK是1.3的,写JAVA代理时也需要自己写这个函数
import java.util.*;
public class test
{
public static void main(String args[])
{
Vector v = new Vector();
test t = new test();
v = t.splitString("b","aaabccccbddddbeeeeee");
System.out.println(v.size());
for (int i = 0;i<v.size();i++)
{
System.out.println(v.get(i));
}
}
public Vector splitString(String sign, String sourceString)
{
Vector splitArrays = new Vector();
int i = 0;
int j = 0;
if (sourceString.length()==0) {return splitArrays;}
while (i <= sourceString.length()) {
j = sourceString.indexOf(sign, i);
if (j < 0) {j = sourceString.length();}
splitArrays.addElement(sourceString.substring(i, j));
i = j + 1;
}
return splitArrays;
}
}