Here you can find the source of readStream(Reader r)
Parameter | Description |
---|---|
IOException | an exception |
public static String readStream(Reader r) throws IOException
//package com.java2s; /*/*from ww w .j a v a2 s . c o m*/ * Copyright (c) 2015. Philip DeCamp * Released under the BSD 2-Clause License * http://opensource.org/licenses/BSD-2-Clause */ import java.io.*; public class Main { /** * Puts the whole stream into the string. * Don't do this if the stream is too big, obviously. * @throws IOException */ public static String readStream(Reader r) throws IOException { StringBuffer buffer = new StringBuffer(); BufferedReader br = new BufferedReader(r); String line; while ((line = br.readLine()) != null) { buffer.append(line); } return buffer.toString(); } }