j2me中StringToKenizer的替代方法[原創(chuàng)]
發(fā)表時(shí)間:2024-01-27 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]j2me的String類中沒有StringToKenizer如此重要的類,而事實(shí)上,在rms的讀取數(shù)據(jù)過程中經(jīng)常會(huì)用到字符串的分割這里我寫了一個(gè)功能類似的函數(shù),共享出來// split a string with symblo,return vecotrpublic Vector stringSp...
j2me的String類中沒有StringToKenizer如此重要的類,
而事實(shí)上,在rms的讀取數(shù)據(jù)過程中經(jīng)常會(huì)用到字符串的分割
這里我寫了一個(gè)功能類似的函數(shù),共享出來
// split a string with symblo,return vecotr
public Vector stringSplit(String symbol, String source) {
Vector tmp = new Vector();
String str = source;
int length = str.length();
int slen = symbol.length();
int index = 0;
int start = 0;
while ( (index = str.indexOf(symbol)) != -1 ) {
tmp.add(str.substring(start, index));
str = str.substring(index+slen, length);
length = str.length();
start = index+slen;
}
tmp.add(str);
return tmp;
}