Here you can find the source of getFileContentAsString(final String filePath)
public static String getFileContentAsString(final String filePath) throws IOException
//package com.java2s; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Main { /**// ww w .j a va 2 s . c o m * reads file and concatenate content to a string */ public static String getFileContentAsString(final String filePath) throws IOException { final StringBuffer fileData = new StringBuffer(1000); final BufferedReader reader = new BufferedReader(new FileReader( filePath)); char[] buf = new char[1024]; int numRead = 0; while ((numRead = reader.read(buf)) != -1) { final String readData = String.valueOf(buf, 0, numRead); fileData.append(readData); buf = new char[1024]; } reader.close(); return fileData.toString(); } }