Here you can find the source of readFile(File file)
public static String readFile(File file)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFile(File file) { String allText = null;//from w ww . j a v a 2s . co m try { FileReader fileReader = new FileReader(file); BufferedReader bufferedReader = new BufferedReader(fileReader); StringBuffer stringBuffer = new StringBuffer(); String line; while ((line = bufferedReader.readLine()) != null) { stringBuffer.append(line); stringBuffer.append("\n"); } fileReader.close(); allText = stringBuffer.toString(); } catch (IOException e) { e.printStackTrace(); } return allText; } }