Here you can find the source of getFileContent(String filename)
public static String getFileContent(String filename) throws IOException
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.LineNumberReader; public class Main { public static String getFileContent(String filename) throws IOException { File file = new File(filename); if (!file.exists()) { return null; }/*from www. ja v a 2 s . c o m*/ StringBuffer result = new StringBuffer(); FileInputStream fis = new FileInputStream(file); InputStreamReader reader = new InputStreamReader(fis, "UTF-8"); LineNumberReader lineReader = new LineNumberReader(reader); String line; while ((line = lineReader.readLine()) != null) { if (line.trim().equals("")) continue; result.append(line.trim()).append('\n'); } lineReader.close(); reader.close(); fis.close(); return result.toString(); } }