Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.FileInputStream;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

public class Main {
    public static void main(String[] args) throws Exception {
        FileInputStream fis = new FileInputStream("test.txt");
        FileChannel fc = fis.getChannel();

        long startRegion = 0;
        long endRegion = fc.size();
        MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_ONLY, startRegion, endRegion);
        while (mbb.hasRemaining()) {
            System.out.print((char) mbb.get());
        }
        fis.close();
    }
}