Using FileWriter:
- import java.io.File;
- import java.io.FileWriter;
- public class WriteByFileWriterExe {
- public static void main(String[] args) throws Exception {
- File file = new File("D:\\data1.txt");
- FileWriter fw = new FileWriter(file);
- for (int i = 0; i < 5; i++) {
- fw.write("using FileWriter !!");
- fw.append("\n");
- }
- fw.close();
- }
- }
Output:
using FileWriter !!
using FileWriter !!
using FileWriter !!
using FileWriter !!
using FileWriter !!
No comments:
Post a Comment