Here you can find the source of readFile(Reader reader)
public static String readFile(Reader reader) throws IOException
//package com.java2s; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.Reader; public class Main { public static String readFile(Reader reader) throws IOException { return readerToString(reader); }/*from w w w . j a va 2 s . c o m*/ public static String readFile(File f) throws IOException { FileReader reader = new FileReader(f); return readFile(reader); } public static String readFile(String filename) throws IOException { return readFile(new File(filename)); } public static String readerToString(Reader is) throws IOException { StringBuffer sb = new StringBuffer(); char[] b = new char[4 * 1024]; int n = is.read(b); // Read a block. If it gets any chars, append them. while (n > 0) { sb.append(b, 0, n); n = is.read(b); } // Only construct the String object once, here. String s = sb.toString(); // log.debug(this, "file contents:\n\t" + s); return (s); } }