Here you can find the source of readFile(File filename)
public synchronized static String readFile(File filename) 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.InputStream; import java.io.InputStreamReader; public class Main { public synchronized static String readFile(String filename) throws IOException { return readFile(new File(filename)); }/*from w w w . jav a 2 s . c om*/ public synchronized static String readFile(File filename) throws IOException { StringBuilder result = new StringBuilder(); InputStream ips = new FileInputStream(filename); InputStreamReader ipsr = new InputStreamReader(ips); try (BufferedReader br = new BufferedReader(ipsr)) { String line; while ((line = br.readLine()) != null) { result.append(line).append("\n"); } } return result.toString(); } }