5

パイプ区切りのデータをタブ区切りまたはカンマ区切りの形式に変換する必要があります。私はJavaで次のメソッドを書きました:

public ArrayList<String> loadData(String path, String fileName){
    File tempfile;
    try {//Read File Line By Line
        tempfile = new File(path+fileName);
        FileInputStream fis = new FileInputStream(tempfile);
        DataInputStream in = new DataInputStream(fis);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        String strLine;
        int i = 0;
        while ((strLine = br.readLine()) != null)   {
            strLine.replaceAll("\\|", ",");
            cleanedData.add(strLine);
            i++;
        }
    }
    catch (IOException e) {
        System.out.println("e for exception is:"+e);
        e.printStackTrace();
    }
    return cleanedData;
}

問題は、結果のデータがまだパイプで区切られていることです。タブ区切りまたはカンマ区切りのデータを返すように、上記のコードを修正する方法を教えてもらえますか?

4

1 に答える 1