Writing to an already existing file using FileWriter Java

后端 未结 2 1971
一整个雨季
一整个雨季 2020-12-19 01:25

Is there anyway I can write to an already existing file using Filewriter

For example when the user clicks a submit button:

FileWriter writer = new Fi         


        
相关标签:
2条回答
  • 2020-12-19 01:53

    Yeah. Use the constructor like this:

    FileWriter writer = new FileWriter("myfile.csv",true);
    
    0 讨论(0)
  • 2020-12-19 02:09
    FileWriter
    
    public FileWriter(File file,
                      boolean append)
               throws IOException
    
    Constructs a FileWriter object given a File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning. 
    
    0 讨论(0)
提交回复
热议问题