"00000000001 ",1,"21-4-8-1","J288","1",4,491441.78999999998,3306097.5589999999,,1,0.88,,1,3,"","","00000000001 ",2,"21-4-8-1","J290","2",4,491440.97399999999,3306097.2319999998,,1,0.80000000000000004,,1,1,"","","00000000001 ",3,"21-4-8-1","J292","3",4,491440.24400000001,3306096.8930000002,,1,16.449999999999999,,1,3,"","","00000000001 ",4,"21-4-8-1","J367","4",4,491446.39000000001,3306081.6290000002,,1,11.82,,2,1,"","","00000000001 ",5,"21-4-8-1","J377","5",4,491434.78399999999,3306079.4029999999,,1,10.74,,2,3,"","","00000000001 ",6,"21-4-8-1","J389","6",4,491424.34100000001,3306076.912,,1,0.51000000000000001,,1,3,"","","00000000001 ",7,"21-4-8-1","J386","7",4,491424.10100000002,3306077.3670000001,,1,5.8200000000000003,,1,3,"","","00000000001 ",8,"21-4-8-1","J360","8",4,491422.94099999999,3306083.071,,1,6.5999999999999996,,1,3,"","","00000000001 ",9,"21-4-8-1","J329","9",4,491424.28399999999,3306089.5359999998,,1,9.4700000000000006,,1,3,"","","00000000001 ",10,"21-4-8-1","J284","10",4,491421.42300000001,3306098.5690000001,,1,7.6600000000000001,,1,3,"","","00000000001 ",11,"21-4-8-1","J272","11",4,491428.565,3306101.3360000001,,1,0.25,,1,3,"","","00000000001 ",12,"21-4-8-1","J270","12",4,491428.47999999998,3306101.571,,1,10.949999999999999,,1,3,"","","00000000001 ",13,"21-4-8-1","J251","13",4,491438.772,3306105.307,,1,8.3100000000000005,,1,3,"","","00000000001 ",14,"21-4-8-1","J288","1",4,491441.78999999998,3306097.5589999999,,1,,,,,"","","00000000002 ",1,"21-5-10-1","J4","1",4,493130.78999999998,3306015.6899999999,,1,9.4499999999999993,,2,3,"","","00000000002 ",2,"21-5-10-1","J5","2",4,493138.054,3306009.6499999999,,1,9.7699999999999996,,2,3,"","","00000000002 ",3,"21-5-10-1","J14","3",4,493131.652,3306002.2680000002,,1,9.5800000000000001,,2,3,"","","00000000002 ",4,"21-5-10-1","J7","4",4,493124.49599999998,3306008.6310000001,,1,9.4600000000000009,,2,3,"","","00000000002 ",5,"21-5-10-1","J4","1",4,493130.78999999998,3306015.6899999999,,1,,,,,"",""
需求:这是一个杂乱无章的文本文件,大约有1M左右,现在需要从"",""后面开始换行,并且去掉后面的逗号
格式如些"00000000001 ",1,"21-4-8-1","J288","1",4,491441.78999999998,3306097.5589999999,,1,0.88,,1,3,"",""
"00000000001 ",2,"21-4-1","J290","2",4,491440.97399999999,3306097.2319999998,,1,0.80000000000000004,,1,1,"",""
可以读文件 然后经过处理再写入到令一个文本中 请各位支支招 明天早上就要 晚上又是一个不眠夜了

解决方案 »

  1.   

    package _6for18;import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;public class Spilet { /**
     * @param args
     */
    public static void main(String[] args) {
    BufferedReader br = null; 
    BufferedWriter bw = null; 
    try {
    bw = new BufferedWriter(new FileWriter("d:/bbcf.txt"));
    br = new BufferedReader(new FileReader("d:/aa.txt"));
    String line = null;
    while((line = br.readLine())!=null){
    line = line.replace(",", "\r\n");
    bw.write(line);
    bw.flush();
    }
    } catch (FileNotFoundException e) {
    System.out.println("file not found");
    } catch (IOException e){
    System.out.println("file reader error!!");
    }finally{
    close(br,bw);
    } } private static void close(BufferedReader br, BufferedWriter bw) {
    if(br!=null){
    try {
    br.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    if(bw!=null){
    try {
    bw.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }}
      

  2.   

    哥们 不行啊 我的QQ是313463133 咱们QQ聊啊 请教下啊
      

  3.   


    public static void main(String[] args) throws Exception {
    FileInputStream fis = new FileInputStream("e:/file.txt");//输入文件
    StringBuffer temp = new StringBuffer();
    byte[] buffer = new byte[1024];
    int pos = 0;
    while((pos = fis.read(buffer)) != -1){
    temp.append(new String(buffer,0,pos));
    }
    fis.close();
    String tar = temp.toString();
    FileOutputStream fos = new FileOutputStream("e:/result.txt");//输出文件
    fos.write(tar.replaceAll("\"\",\"\",", "\r\n").getBytes());
    fos.close();
      }快洗洗睡吧.
      

  4.   

    oh,看错结果了.倒数第二行改一下.
    fos.write(tar.replaceAll("\"\",\"\",", "\"\",\"\"\r\n").getBytes());