Android BufferedReader Read readStream(Reader r)

Here you can find the source of readStream(Reader r)

Description

Puts the whole stream into the string.

License

Open Source License

Exception

Parameter Description
IOException an exception

Declaration

public static String readStream(Reader r) throws IOException 

Method Source Code

//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();
    }
}

Related

  1. getFileContent(File f)
  2. readFileAsString(File file)
  3. readFileFolder(String filePath)
  4. readStringFromBufferedReader(BufferedReader br)
  5. toList(String fileName)