Here you can find the source of readFile(final String file)
static String readFile(final String file) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { static String readFile(final String file) throws IOException { BufferedReader reader = null; try {//w w w. ja v a 2s.c o m reader = new BufferedReader(new FileReader(new File(file))); final StringBuilder sb = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { sb.append(line); sb.append(System.getProperty("line.separator")); } return sb.toString(); } finally { if (reader != null) { reader.close(); } } } }