File Java Tutorial

A channel for a physical file: provides an efficient mechanism for reading, writing, and manipulating the file.

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();
  }
}