Here you can find the source of getFileContents(Reader reader)
public static String getFileContents(Reader reader) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String getFileContents(String fileName) throws Exception { return getFileContents(fileName, 4096); }/*ww w .jav a 2 s . c o m*/ public static String getFileContents(File file) throws Exception { try { return getFileContents(new BufferedReader(new FileReader(file), 4096)); } catch (Exception e) { System.err.println("Exception getting contents for file " + file.getName() + ": " + e); throw e; } } public static String getFileContents(String fileName, int bufLen) throws Exception { try { return getFileContents(new BufferedReader(new FileReader(fileName), bufLen)); } catch (Exception e) { System.err.println("Exception getting contents for file " + fileName + ": " + e); throw e; } } public static String getFileContents(Reader reader) throws Exception { StringBuilder sb = new StringBuilder(); for (int c = reader.read(); c >= 0; c = reader.read()) { sb.append((char) c); } return sb.toString(); } }