@Blocking
    public static String readText(BufferedReader reader) throws IOException {
        StringBuilder answer = new StringBuilder();
        if (reader == null) {
            return answer.toString();
        }
        // reading the content of the file within a char buffer
        // allow to keep the correct line endings
        char[] charBuffer = new char[BUFFER_MAX];
        int nbCharRead /* = 0*/;
        try {
            while ((nbCharRead = reader.read(charBuffer)) != -1) {
                // appends buffer
                answer.append(charBuffer, 0, nbCharRead);
            }
            Reader temp = reader;
            reader = null;
            temp.close();
        } finally {
            try {
                if (reader != null) {
                    reader.close();
                }
            } catch (IOException e) {
                if (LOG.isWarnEnabled()) {
                    LOG.warn("Failed to close reader: " + e.getMessage(), e);
                }
            }
        }
        return answer.toString();
    }
@ Blocking public static String readText ( BufferedReader reader ) throws IOException { StringBuilder answer = new StringBuilder ( ) ; if ( reader == null ) { return answer . toString ( ) ; } char [ ] charBuffer = new char [ BUFFER_MAX ] ; int nbCharRead ; try { while ( ( nbCharRead = reader . read ( charBuffer ) ) != - 1 ) { answer . append ( charBuffer , 0 , nbCharRead ) ; } Reader temp = reader ; reader = null ; temp . close ( ) ; } finally { try { if ( reader != null ) { reader . close ( ) ; } } catch ( IOException e ) { if ( LOG . isWarnEnabled ( ) ) { LOG . warn ( "Failed to close reader: " + e . getMessage ( ) , e ) ; } } } return answer . toString ( ) ; }
Read the content of the BufferedReader and return it as a String in a blocking manner.
The BufferedReader is closed afterwards.

@param reader a BufferedReader whose content we want to read
@return a String containing the content of the buffered reader
@throws IOException if an IOException occurs.
@since 1.0