FileOutputStreamDemo.java Source code

Java tutorial

Introduction

Here is the source code for FileOutputStreamDemo.java

Source

import java.io.FileOutputStream;

class FileOutputStreamDemo {

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

        FileOutputStream fos = new FileOutputStream(args[0]);

        // Write 12 bytes to the file
        for (int i = 0; i < 12; i++) {
            fos.write(i);
        }

        // Close file output stream
        fos.close();
    }
}