protected byte[] readFully(InputStream in) throws Exception {
  ByteArrayOutputStream out=new ByteArrayOutputStream();
  byte[] buffer=new byte[32];
  int count;
  while ((count=in.read(buffer)) >= 0) {
    out.write(buffer,0,count);
  }
  return out.toByteArray();
}

protected byte [ ] readFully ( InputStream in ) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; byte [ ] buffer = new byte [ 32 ] ; int count ; while ( ( count = in . read ( buffer ) ) >= 0 ) { out . write ( buffer , 0 , count ) ; } return out . toByteArray ( ) ; }
reads an input stream into a byte array .
