Append String to a file with FileWriter in Java
Description
The following code shows how to append String to a file with FileWriter.
Example
/*from w ww .j av a2s.c o m*/
import java.io.File;
import java.io.FileWriter;
public class Main {
public static void main(String[] args) throws Exception{
File file = new File("myFile.txt");
FileWriter writer = new FileWriter(file, true);
writer.write("java2s.com" + System.getProperty("line.separator"));
writer.flush();
writer.close();
}
}