BufferedWriterDemo.java Source code

Java tutorial

Introduction

Here is the source code for BufferedWriterDemo.java

Source

import java.io.BufferedWriter;
import java.io.FileWriter;

class BufferedWriterDemo {

    public static void main(String args[]) throws Exception {

        FileWriter fw = new FileWriter(args[0]);

        BufferedWriter bw = new BufferedWriter(fw);

        // Write strings to the file
        for (int i = 0; i < 12; i++) {
            bw.write("Line " + i + "\n");
        }

        // Close buffered writer
        bw.close();
    }
}