Here you can find the source of loadText(Reader reader, int length)
public static char[] loadText(Reader reader, int length) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static char[] loadText(Reader reader, int length) throws IOException { char[] chars = new char[length]; int count = 0; while (count < chars.length) { int n = reader.read(chars, count, chars.length - count); if (n <= 0) break; count += n;/*w w w . java 2s.c o m*/ } if (count == chars.length) { return chars; } else { char[] newChars = new char[count]; System.arraycopy(chars, 0, newChars, 0, count); return newChars; } } }