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.*; public class Main { /** read file with lines separated by LF */ public static String readFile(File file) throws Exception { StringBuilder sb = new StringBuilder(); try (BufferedReader br = new BufferedReader(new FileReader(file))) { String l;//from w ww . ja v a2 s. co m while ((l = br.readLine()) != null) { sb.append(l).append("\n"); } } return sb.toString(); } }