Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileInputStream;

import java.nio.ByteBuffer;

public class Main {
    public static String readTxtFromFile(File file) throws Exception {
        ByteBuffer buffer = ByteBuffer.allocate((int) file.length());
        FileInputStream in = new FileInputStream(file);
        in.getChannel().read(buffer);
        in.close();
        return new String(buffer.array());
    }
}