拆分字符串的JAVA函数
作者:未知 来源:geoff 添加时间:2006-5-21 11:17:12这是我写的一个拆分函数,将字符串拆分到hashtable中
public static Hashtable spilt(String fieldsru, String tag)
{
Hashtable returnarray = new Hashtable();
char dot = tag.charAt(0);
String field;
field = fieldsru + dot;
int num = 0;
int field_len = field.length();
for (int i = 0; i < field_len; i++)
{
if (field.charAt(i) == dot)
{
num++;
}
}
int begin = 0;
int end;
for (int j = 0; j < num; j++)
{
end = field.indexOf(dot, begin);
returnarray.put(new Integer(j), field.substring(begin, end));
begin = end + 1;
}
return returnarray;
}
站内搜索