A
A
Anton Peat2014-12-17 17:01:48
Java
Anton Peat, 2014-12-17 17:01:48

How to add a new line to the end of a file?

WriteToFile("studentsapp22.txt", rcet.getText().toString());

This line only overwrites the file, and I really need a list in it.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
axmexa, 2014-12-17
@id_aspin

try {
    PrintWriter prWr = new PrintWriter(new BufferedWriter(new FileWriter("somefile.txt", true)));
    prWr .println("the text");
    prWr .close();
} catch (IOException e) {
    e.printStackTrace();
}

B
Boris Benkovsky, 2014-12-17
@benbor

bit.ly/1z3UU9n

A
Anton Peat, 2014-12-17
@id_aspin

1) WriteToFile function does not exist in android java. Taken a separate script.
2) You can solve the problem like this: Read the entire file line by line + "\n", complete and write back.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question