public static String readString ( final InputStream stream ) throws IOException { InputStreamReader br = null ; StringBuilder sb = new StringBuilder ( ) ; try { br = new InputStreamReader ( stream ) ; int got ; while ( ! Thread . currentThread ( ) . isInterrupted ( ) ) { got = br . read ( ) ; if ( got == - 1 ) { break ; } sb . append ( ( char ) got ) ; } } finally { if ( br != null ) { try { br . close ( ) ; } catch ( final IOException ex ) { } } } return sb . toString ( ) ; }
Reads a string from the input stream .