Using BufferedWriter:
Output:
writing data using BufferedWriter. Isn't it interesting !! :)
writing data using BufferedWriter. Isn't it interesting !! :)
writing data using BufferedWriter. Isn't it interesting !! :)
writing data using BufferedWriter. Isn't it interesting !! :)
writing data using BufferedWriter. Isn't it interesting !! :)
- import java.io.File;
- import java.io.FileWriter;
- import java.io.BufferedWriter;
- import java.io.IOException;
- public class WriteByBufferedWriterExe {
- public static void main(String[] args) throws IOException {
- String contents = "writing data using BufferedWriter. Isn't it interesting !!)";
- File file = new File("D:\\data1.txt");
- FileWriter fw = new FileWriter(file);
- BufferedWriter bw = new BufferedWriter(fw);
- for (int i = 0; i < 5; i++) {
- bw.write(contents);
- bw.newLine(); // bw.append("\n");
- }
- bw.close();
- }
- }
Output:
writing data using BufferedWriter. Isn't it interesting !! :)
writing data using BufferedWriter. Isn't it interesting !! :)
writing data using BufferedWriter. Isn't it interesting !! :)
writing data using BufferedWriter. Isn't it interesting !! :)
No comments:
Post a Comment