How do i write to a text file WITHOUT deleting the current information in it? basically write on the next available line.

Recommended Answers

All 2 Replies

That sounds like you want to APPEND to the end of the current file.
Read the API doc for the file output classes. One of the constructors takes a boolean specifying whether to append or not.

try {
    BufferedWriter out = new BufferedWriter(new FileWriter("example.txt", true));
    out.write("aString");
    out.close();
} catch (IOException e) {
}

Just make sure "true" is the 2nd argument, it says to append or not.

Hope this helps!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.