MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;

public class MainClass {
    public static void main(String[] a) {
        File aFile = new File("C:/myFile.text");
        FileOutputStream outputFile = null; // Place to store an output stream
                                            // reference
        try {
            // Create the stream opened to write
            outputFile = new FileOutputStream(aFile);
        } catch (FileNotFoundException e) {
            e.printStackTrace(System.err);
            System.exit(1);
        }
        // Get the channel for the file
        FileChannel outputChannel = outputFile.getChannel();
    }
}