public static String read ( InputStream in ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; byte [ ] buffer = new byte [ 1024 ] ; int length = 0 ; while ( ( length = in . read ( buffer ) ) != - 1 ) { baos . write ( buffer , 0 , length ) ; } return new String ( baos . toByteArray ( ) ) ; }
Read the entire input stream in 1KB chunks