Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.*;

public class Main {
    public static String readFromFile(File file) {
        try (Reader in = new InputStreamReader(new FileInputStream(file), "UTF-8")) {
            char[] arr = new char[(int) file.length()];
            int len = in.read(arr);
            return new String(arr, 0, len);
        } catch (IOException ex) {
            throw new RuntimeException("Unable to read file " + file.getName(), ex);
        }
    }
}