Here you can find the source of readFile(final File file)
public static String readFile(final File file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String readFile(final File file) throws IOException { final StringBuilder sb = new StringBuilder(); try (final BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(file)))) { String line = null;// w ww.j av a 2 s.c o m while ((line = reader.readLine()) != null) { sb.append(line); sb.append("\n"); } } return sb.toString(); } }