Here you can find the source of loadContents(File file)
public static String loadContents(File file) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static String loadContents(File file) throws IOException { if (file == null) { throw new IllegalArgumentException(); }// w ww.j a v a 2 s.c o m if (!file.exists() || file.isDirectory()) { return null; } BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "utf-8")); String s = null; StringBuilder sb = new StringBuilder(); while ((s = br.readLine()) != null) { sb.append(s); sb.append("\r\n"); } return sb.toString(); } finally { if (br != null) { br.close(); } } } }