Given InputStream replace character and produce OutputStream

后端 未结 3 1008
温柔的废话
温柔的废话 2021-01-22 07:10

I have a lot of massive files I need convert to CSV by replacing certain characters.

I am looking for reliable approach given InputStream return OutputStream and replac

3条回答
  •  旧巷少年郎
    2021-01-22 07:29

                FileWriter writer = new FileWriter("Report.csv");
                BufferedReader reader = new BufferedReader(new InputStreamReader(YOURSOURCE, Charsets.UTF_8));
                String line;
                while ((line = reader.readLine()) != null) {
                    line.replace('c1', 'c2');
                    writer.append(line);
                    writer.append('\n');
                }
                writer.flush();
                writer.close();
    

提交回复
热议问题