Here you can find the source of loadAFileToString2(File f)
public static String loadAFileToString2(File f)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static String loadAFileToString2(File f) { InputStream is = null;/* w w w. j a v a2 s.c o m*/ String ret = ""; if (f.exists()) { BufferedReader br = null; try { String line; is = new FileInputStream(f); InputStreamReader read = new InputStreamReader(is, "utf-8"); br = new BufferedReader(read); while ((line = br.readLine()) != null) { ret += line + "\r\n"; } } catch (Exception e) { ret = ""; } finally { if (is != null) { try { is.close(); } catch (Exception e) { } } } } return ret; } }