code: public static byte[] readAll(InputStream bytes) throws IOException {
      ByteArrayOutputStream builder = new ByteArrayOutputStream();
      int read = bytes.read();
      while (read != -1) {
        builder.write(read);
        read = bytes.read();
      }
      builder.flush();
      bytes.close();
      return builder.toByteArray();
    }
docs: Read all of the bytes in an input stream.
  
  @param bytes the {@link InputStream} of bytes to read
  @return an array of all bytes retrieved from the stream
  @throws IOException if the stream fails