您的位置:首页 > 其它

string split 的缺陷,",a,,"如何截取数组长度为4

2011-11-18 17:10 176 查看
public static String[] getStringArray(String s){

String b = s.replace(",", "','");

if(b.charAt(0)=='\''){

b = "'"+b;

}

if(b.charAt(b.length()-1)=='\''){

b = b + "'";

}

String[] str = b.split(",");

String[] new_str = new String[]{};

for(int i=0;i<str.length;i++){

if(str[i].split("'").length>0){

new_str[i] = str[i].split("'")[1];

}else{

new_str[i] = str[i];

}

}

return new_str;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐