how to edit my compare method

前端 未结 5 1544
孤城傲影
孤城傲影 2021-01-27 09:27

I want to compare contens of my two txt files and write the different words in other file3.txt file

I want to do compare method in this way to write another txt file. A

5条回答
  •  孤街浪徒
    2021-01-27 10:14

    I think you have to flush() your writer before closing it.

    private static void write(ArrayList out, String fname) throws IOException {
        FileWriter writer = new FileWriter(new File("D:\\Denemeler\\deneme3.txt"));
        for (int i = 0; i < out.size(); i++) {
            writer.write(out.get(i) + "\n");
        }
        // Flush the writer before closing it.
        writer.flush();
    
        writer.close();
    }
    

提交回复
热议问题