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 com.google.common.io.CharStreams;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static String readFileToString(final Class contextClass, final String streamIdentifier)
            throws IOException {

        InputStreamReader inputStreamReader = null;
        try {
            inputStreamReader = new InputStreamReader(contextClass.getResourceAsStream(streamIdentifier));
            return CharStreams.toString(inputStreamReader);
        } catch (IOException e) {
            throw new IOException();
        } finally {
            if (inputStreamReader != null) {
                inputStreamReader.close();
            }
        }
    }
}