Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

public class Main {
    public static void main(String[] args) throws IOException {

        byte b[] = { 65, 66, 67, 68, 69 };

        FileOutputStream fos = new FileOutputStream("C://test.txt");

        fos.write(b);

        // pushes stream content to the underlying file
        fos.flush();

        // returns file channel associated with this stream
        FileChannel fc = fos.getChannel();

        // returns the number of bytes written
        long pos = fc.position();

        System.out.print(pos);

    }
}