code: public static byte[] readFully(InputStream stream) throws IOException
      {
          Checks.notNull(stream, "InputStream");
  
          byte[] buffer = new byte[1024];
          try (ByteArrayOutputStream bos = new ByteArrayOutputStream())
          {
              int readAmount = 0;
              while ((readAmount = stream.read(buffer)) != -1)
              {
                  bos.write(buffer, 0, readAmount);
              }
              return bos.toByteArray();
          }
      }
docs: Provided as a simple way to fully read an InputStream into a byte[].
  
  <p>This method will block until the InputStream has been fully read, so if you provide an InputStream that is
  non-finite, you're gonna have a bad time.
  
  @param  stream
  The Stream to be read.
  
  @throws IOException
  If the first byte cannot be read for any reason other than the end of the file,
  if the input stream has been closed, or if some other I/O error occurs.
  
  @return A byte[] containing all of the data provided by the InputStream