Here you can find the source of getFileContents(final String absFilePath)
public static String getFileContents(final String absFilePath)
//package com.java2s; //License from project: Open Source License import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.nio.charset.Charset; public class Main { public static String getFileContents(final String absFilePath) { String data = null;/*from w ww . j av a 2s. c om*/ if (absFilePath != null) { File file = new File(absFilePath); if (file.isFile()) { byte[] buffer = new byte[4096]; BufferedInputStream bis = null; try { int readSize = 0; StringBuilder builder = new StringBuilder(); bis = new BufferedInputStream(new FileInputStream(file), 4096); while ((readSize = bis.read(buffer)) > 0) { builder.append(new String(buffer, 0, readSize, Charset.forName("UTF-8"))); } data = builder.toString(); bis.close(); } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } } else { log("Specified path is not a file : " + absFilePath); } } return data; } public static void log(String str) { System.out.println(str); } }