private static byte [ ] readAll ( InputStream is ) throws IOException { ByteArrayOutputStream tmp = new ByteArrayOutputStream ( ) ; byte [ ] buf = new byte [ 2000 ] ; int read = 0 ; do { read = is . read ( buf ) ; tmp . write ( buf , 0 , read ) ; } while ( ( read > 0 ) && ( is . available ( ) > 0 ) ) ; return tmp . toByteArray ( ) ; }
reads all available bytes from the stream