Here you can find the source of readAll(Reader rd)
public static String readAll(Reader rd)
//package com.java2s; /******************************************************************************* * Copyright (c) 2009 xored software, Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w . j a v a 2 s.c o m * xored software, Inc. - initial API and Implementation (Alex Panchenko) *******************************************************************************/ import java.io.IOException; import java.io.Reader; public class Main { public static String readAll(Reader rd) { final StringBuilder buffer = new StringBuilder(); char[] readBuffer = new char[2048]; try { int n = rd.read(readBuffer); while (n > 0) { buffer.append(readBuffer, 0, n); n = rd.read(readBuffer); } return buffer.toString(); } catch (IOException x) { } return null; } }