//先去除" ",得到"...................................."這樣的一個(gè)字符串,然后再去除一頭一尾的引號(hào)
public static void replaceChar(String s){
??????? //String s = "01290943050280128550\" \"01\" \"0\" \"13548418074\" \"923041\" \"13548418074\" \"1862????? \" \"1862SMS?? \" \"01\" \"0???? \" \"0???? \" \"0????? \" \"0\" \"85 \" \"280 \" \"002801\" \"????? \" \"13800280500\" \"20070129094305\" \"20070129094314\" \"PXY08 \" \"0";
??????? String ss = s.replaceAll("\" \"","");
??????? System.out.println(" ss ="+ss);
??????? ss = ss.replaceAll("\"","");
??????? System.out.println(" ss ="+ss);
??? }
?public static void readFile(){
??????? try{
??????????? File file = new File("D:\\dosp\\t.txt");
??????????? java.io.FileReader reader = new FileReader(file);
??????????? BufferedReader br = new BufferedReader(reader);
??????????? String s = br.readLine();
??????????? System.out.println(" s = " + s);
??????????? replaceChar(s);
??????? }catch(Exception e){
??????????? e.printStackTrace();
??????? }
??? }
?public static void main(String[] args) {
??????? Test test = new Test();
??????? readFile();
??? }
以下是在文本t.txt中的例子(處于一行,每個(gè)字段用引號(hào)括住,各個(gè)字段之間有空格)
"01282356000280118304" "01" "0" "?????????? " "923084" "13466390573" "5198????? " "-GSSP???? " "03" "0???? " "1500? " "DB:0115" "1" "101" "??? " "002801" "????? " "13800280500" "20070128235602" "20070128235602" "Agent0" "0???????? "
進(jìn)過(guò)上面函數(shù)處理后得到:
第一步得到:
"01282356000280118304010?????????? 923084134663905735198????? -GSSP???? 030???? 1500? DB:01151101??? 002801????? 138002805002007012823560220070128235602Agent00???????? "
第二步得到:
01282356000280118304010?????????? 923084134663905735198????? -GSSP???? 030???? 1500? DB:01151101??? 002801????? 138002805002007012823560220070128235602Agent00????????