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.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Main { public static String readFile(File file) { Scanner scan;// w ww . j a va2s . c om try { scan = new Scanner(file); } catch (FileNotFoundException e1) { e1.printStackTrace(); return null; } String content = scan.useDelimiter("\\Z").next(); content = content.replaceAll("\\r", ""); scan.close(); return content; } }