Writing multiline JTextArea content into file

前端 未结 1 745
别那么骄傲
别那么骄傲 2020-12-04 01:21

I have to write the content of textarea into a file with line breaks. I got the output like, it is written as one string in the file.

public void actionPerfo         


        
相关标签:
1条回答
  • 2020-12-04 01:42

    Use JTextComponent.write(Writer):

    Stores the contents of the model into the given stream. By default this will store the model as plain text.

    E.G.

    BufferedWriter writer = new BufferedWriter(new FileWriter("filename.txt"));
    text.write(writer);
    
    0 讨论(0)
提交回复
热议问题