file writer doesn't work

后端 未结 5 447
野性不改
野性不改 2020-12-19 14:28

I use a FileWriter and a BufferWriter to write in a file. The file \"test.txt\" is created but nothing is written inside.

The file should be written in the ActionEve

5条回答
  •  渐次进展
    2020-12-19 15:09

    Follow these Sequence to successfully write to a file....

    File f = new File("d:\\test.txt");
    
    FileWriter fw = new FileWriter(f);
    
    BufferedWriter bw = new BufferedWriter(fw);
    
    bw.write("Hello........");        // Writing to the file
    
    bw.close();                       // Close the BufferedWriter
    
    fw.close();                       // Close the FileWriter
    

    Closing of Streams are important....

提交回复
热议问题