Java BufferedReader to String bufferToString(BufferedReader br)

Here you can find the source of bufferToString(BufferedReader br)

Description

buffer To String

License

Open Source License

Declaration

private static String bufferToString(BufferedReader br) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;

public class Main {
    private static String bufferToString(BufferedReader br) throws Exception {
        StringBuffer sb = new StringBuffer();
        try {//  ww w.j  a  v a2 s.  c  o  m
            for (String s = null; (s = br.readLine()) != null;)
                sb.append(s + "\n");

        } catch (Exception e) {
            throw new Exception("Error reading the buffer: " + e.getMessage());
        }
        return sb.toString();
    }
}

Related

  1. loadText(BufferedReader reader)