how can i write data to a file without erasing old content
Use new FileOutputStream(file, true). This will open the file in "append" mode, which will add all the data written to the stream at the end of this file.
new FileOutputStream(file, true)
Do you mean "how do you add to a file"? Find [append-version of constructor] [1] of your file writer class, for example:
public FileWriter(String fileName, boolean append) throws IOException
Use this constructor and pass truein the append parameter.
true
[1]: http://download.oracle.com/javase/6/docs/api/java/io/FileWriter.html#FileWriter(java.io.File , boolean)
Java 7,
try (BufferedWriter writer = Files.newBufferedWriter(outFile, StandardCharsets.UTF_8, StandardOpenOption.APPEND))
Source: https://habr.com/ru/post/1782608/More articles:Library for checking connection speed - javaДействительно ли Кассандра готова и достаточно зрелая для производственных сред для больших проектов? - sqlJquery change div created from html before adding - javascriptHow to register for NSNotification from UILocalNotification? - iosConfiguring log4j at runtime - antuntested wpf switches - radio-buttonOptimize linq to sql query with subquery to get the latest result - c #Using two classes with the same name - phpUse textual representations of LINQ expressions - c #C # add progress bar to textBox - c #All Articles