• 0

[Java] Inserting text to an existing file


Question

4 answers to this question

Recommended Posts

  • 0

Look at the java API docs (http://java.sun.com/j2se/1.4.2/docs/api/index.html) for FileWriter. Create a new FileWriter using the FileWriter(File file, boolean append) or FileWriter(String fileName, boolean append) constructors. If append is true, the text will be appended to the file:

FileWriter f = new FileWriter("c:\\my_file", true);

f.write("some text" + "\n");

f.close()

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.