/**
* 分割字符串,先去除所有空格,再去引号操作
* */
protected String[] splitString(String lineString){
ArrayList list = new ArrayList();
StringBuffer sb = new StringBuffer();
String[] temp_columnArray = null;
String[] columnArray = null;
//字符串如果含有空格,则空格为“半角状态下的空格”,如果为全角状态下,则空格长度为1
lineString = lineString.trim();
char[] chars = lineString.toCharArray();
int length = chars.length;
for(int i = 0; i < chars.length; i++){
if(String.valueOf(chars[i]).trim().length()<1){
length --;
}else{
sb.append(String.valueOf(chars[i]));
}
}
System.out.println(sb.toString());
String str = sb.toString();
temp_columnArray = str.split("['\"']");
for(int i = 0; i < temp_columnArray.length; i++){
if(temp_columnArray[i].trim().length()>=1){
list.add(temp_columnArray[i]);
}
}
columnArray = (String[])list.toArray(new String[(temp_columnArray.length/2)-1]);
System.out.println(columnArray.length);
for(int i = 0; i < columnArray.length; i++){
System.out.println(columnArray[i]);
}
return columnArray;
}
字符串范例(处于一行中,并且每个字段有引号): "01290943050280128550" "01" "0" "13548418074" "923041" "13548418074" "1862 " "1862SMS " "01" "0 " "0 " "0 " "0" "85 " "280 " "002801" " 33 " "13800280500" "20070129094305" "20070129094314" "PXY08 " "0 "