private static StringBuilder toStringBuilder ( Readable input ) throws IOException { StringBuilder text = new StringBuilder ( ) ; CharBuffer buffer = CharBuffer . allocate ( BUFFER_SIZE ) ; while ( true ) { int n = input . read ( buffer ) ; if ( n == - 1 ) { break ; } buffer . flip ( ) ; text . append ( buffer , 0 , n ) ; } return text ; }
overhead is worthwhile