Reply to comment
Append String to Text File in Java
Tagged:
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class AppendToFile {
public static void main(String[] args) throws IOException {
String path = "/home/jr/Desktop/file1.txt";
String text = "add this text";
File file = new File(path);
FileWriter writer = new FileWriter(file, true);
writer.append(text);
writer.close();
}
} 


Recent comments
1 week 2 days ago
1 week 5 days ago
2 weeks 1 day ago
2 weeks 3 days ago
3 weeks 1 day ago
4 weeks 3 days ago
4 weeks 6 days ago
5 weeks 4 days ago
9 weeks 1 day ago
15 weeks 1 day ago