Here you can find the source of readFile(File location)
public static String readFile(File location)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String readFile(File location) { if (!location.exists()) return null; BufferedReader br = null; StringBuilder bldr = new StringBuilder(); try {/*w ww. ja va2 s . c o m*/ String sCurrentLine; br = new BufferedReader(new FileReader(location)); while ((sCurrentLine = br.readLine()) != null) { bldr.append(sCurrentLine + "\n"); } } catch (IOException e) { e.printStackTrace(); } finally { try { if (br != null) br.close(); } catch (IOException ex) { ex.printStackTrace(); } } return bldr.toString(); } }