code: public static FileCopyResult retryCopy(
        final ByteSource byteSource,
        final File outFile,
        final Predicate<Throwable> shouldRetry,
        final int maxAttempts
    )
    {
      try {
        StreamUtils.retryCopy(
            byteSource,
            Files.asByteSink(outFile),
            shouldRetry,
            maxAttempts
        );
        return new FileCopyResult(outFile);
      }
      catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
docs: Copy input byte source to outFile. If outFile exists, it is attempted to be deleted.
  
  @param byteSource  Supplier for an input stream that is to be copied. The resulting stream is closed each iteration
  @param outFile     Where the file should be written to.
  @param shouldRetry Predicate indicating if an error is recoverable and should be retried.
  @param maxAttempts The maximum number of assumed recoverable attempts to try before completely failing.
  
  @throws RuntimeException wrapping the inner exception on failure.