Here you can find the source of readTextFile(String text_file_name)
public static String readTextFile(String text_file_name) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileReader; import java.io.BufferedReader; public class Main { public static String readTextFile(String text_file_name) throws Exception { BufferedReader br = new BufferedReader(new FileReader(new File( text_file_name)));//from w w w.ja v a2 s . com StringBuffer buffer = new StringBuffer(); String line = ""; while ((line = br.readLine()) != null) buffer.append(line + "\n"); br.close(); return buffer.toString(); } }