Here you can find the source of getFileContent(String filename)
public static String getFileContent(String filename) throws IOException
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static String getFileContent(String filename) throws IOException { File file = new File(filename); if (!file.exists()) { return null; }/*w w w . j a va2s . co m*/ FileInputStream fis = new FileInputStream(file); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] buff = new byte[1024]; int len = 0; while ((len = fis.read(buff)) != -1) { out.write(buff, 0, len); } out.close(); fis.close(); return out.toString(); } }