Please help! I need to write to the file line with a new line, keeping the same data. Suppose there is a file:

слово1 слово2 

You need to add "word3", and you get the text in the file =>

 слово1 слово2 слово3 

    2 answers 2

     FileWriter wr = new FileWriter(file.txt, true); wr.append("слово 3"); wr.flush(); wr.close(); 
       public FileWriter(File file, boolean append) throws IOException 

      Constructs a FileWriter object given a File object. If the second argument is true, then it will be written.

      Those. create a FileWriter, pass the current file to it, and the second argument is true, and the record will go to the end of the file

      • Suppose: public FileWriter (File "D: /text.txt", true) throws IOException Where do I specify the text I want to write? - gameviktor