vb里面有非常方便将字串拆分为数组的函数,但是java没有提供类似函数
这是我写的一个拆分函数,将字符串拆分到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;
}
这是我写的一个拆分函数,将字符串拆分到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;
}
回复Comments
{commenttime}{commentauthor}
{CommentUrl}
{commentcontent}