Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.BufferedReader;

import java.io.FileNotFoundException;
import java.io.FileReader;

import java.io.IOException;

public class Main {
    public static StringBuilder ReadFileToString(String filename) {
        StringBuilder text = new StringBuilder();
        try {
            BufferedReader bProcFS = new BufferedReader(new FileReader(filename));
            String readLine = null;
            while ((readLine = bProcFS.readLine()) != null) {
                text.append(readLine);
                text.append("\n");
            }
            bProcFS.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return text;
    }
}