code: public static byte[] readStream(InputStream is) throws IOException {
  		try {
  			ByteArrayOutputStream baos = new ByteArrayOutputStream();
  			byte[] buf = new byte[1024 * 10];
  			int read;
  			while ((read = is.read(buf)) >= 0) {
  				baos.write(buf, 0, read);
  			}
  			return baos.toByteArray();
  		} finally {
  			is.close();
  		}
  	}
docs: Reads a byte array from a stream. Closes the stream after reading.
  @param is the stream
  @return the byte array
  @throws IOException if the stream contents could not be read