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.*; public class Main { public static String readFile(File file) { StringBuffer contents = new StringBuffer(); try {/*from ww w . java2 s . c o m*/ FileInputStream fstream = new FileInputStream(file); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String line; while ((line = br.readLine()) != null) { contents.append(line); contents.append("\n"); } in.close(); } catch (IOException e) { throw new RuntimeException("Could not read file " + file, e); } return contents.toString(); } }