code: public static byte[] inputStreamAsByteArray(InputStream inputStream) {
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      try {
        byte[] buffer = new byte[16 * 1024];
        int read;
        while((read = inputStream.read(buffer)) > 0) {
          os.write(buffer, 0, read);
        }
        return os.toByteArray();
      } catch (IOException e) {
        throw LOG.unableToReadInputStream(e);
      }
      finally {
        closeSilently(inputStream);
      }
    }
docs: Returns the input stream as {@link byte[]}.
  
  @param inputStream the input stream
  @return the input stream as {@link byte[]}.