Here you can find the source of readFile(File path)
public static String readFile(File path)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFile(File path) { try {/*w ww .j a va 2s .c o m*/ String line = null; StringBuilder stringBuilder = new StringBuilder(); String ls = System.getProperty("line.separator"); BufferedReader reader = new BufferedReader(new FileReader(path)); try { while ((line = reader.readLine()) != null) { stringBuilder.append(line); stringBuilder.append(ls); } return stringBuilder.toString(); } finally { try { reader.close(); } catch (IOException ignore) { } } } catch (IOException ex) { throw new RuntimeException(ex); } } }