Here you can find the source of getReaderContentAsString(Reader reader)
Parameter | Description |
---|---|
reader | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static String getReaderContentAsString(Reader reader) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.Reader; public class Main { /**/*from ww w . j a v a 2s .c o m*/ * Reads the content of a Reader instance and returns it as a String. * * @param reader * @return the content of a Reader instance as a String * @throws IOException */ public static String getReaderContentAsString(Reader reader) throws IOException { int count; final char[] buffer = new char[2048]; final StringBuilder out = new StringBuilder(); while ((count = reader.read(buffer, 0, buffer.length)) >= 0) { out.append(buffer, 0, count); } return (out.toString()); } }