Here you can find the source of readFile(File file)
public static String readFile(File file) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileReader; public class Main { /**/* w ww . j a v a 2 s. c o m*/ * Reads a file and returns its content as a String. * * @author pedro.costa@xseed.com.br */ public static String readFile(File file) throws Exception { BufferedReader reader = new BufferedReader(new FileReader(file)); String line = null; StringBuilder stringBuilder = new StringBuilder(); String ls = System.getProperty("line.separator"); while ((line = reader.readLine()) != null) { stringBuilder.append(line); stringBuilder.append(ls); } reader.close(); return stringBuilder.toString(); } }