public interface Downloader
| Modifier and Type | Method and Description |
|---|---|
java.io.InputStream |
downloadAndStream(java.net.URL url,
ProgressIndicator indicator)
Gets a stream associated with the content at the given URL.
|
void |
downloadFully(java.net.URL url,
java.io.File target,
java.lang.String checksum,
ProgressIndicator indicator)
Downloads the content at the given URL to the given file.
|
java.io.File |
downloadFully(java.net.URL url,
ProgressIndicator indicator)
Downloads the content at the given URL to a temporary file and returns a handle to that file.
|
static java.lang.String |
hash(java.io.InputStream in,
long fileSize,
ProgressIndicator progress)
Hash the given input stream.
|
@Nullable
java.io.InputStream downloadAndStream(@NonNull
java.net.URL url,
@NonNull
ProgressIndicator indicator)
throws java.io.IOException
url - The URL to fetch.indicator - Facility for showing download progress and logging.null if the
download is cancelled.java.io.IOException@Nullable
java.io.File downloadFully(@NonNull
java.net.URL url,
@NonNull
ProgressIndicator indicator)
throws java.io.IOException
url - The URL to fetch.indicator - Facility for showing download progress and logging.null if the download is cancelled.java.io.IOExceptionvoid downloadFully(@NonNull
java.net.URL url,
@NonNull
java.io.File target,
@Nullable
java.lang.String checksum,
@NonNull
ProgressIndicator indicator)
throws java.io.IOException
url - The URL to fetch.target - The location to download to.checksum - If specified, first check target to see if the given checksum
matches the existing file. If so, returns immediately.indicator - Facility for showing download progress and logging.java.io.IOException@NonNull
static java.lang.String hash(@NonNull
java.io.InputStream in,
long fileSize,
@NonNull
ProgressIndicator progress)
throws java.io.IOException
in - The stream to hash. It will be fully consumed but not closed.fileSize - The expected length of the stream, for progress display purposes.progress - The indicator will be updated with the expected completion fraction.java.io.IOException - IF there's a problem reading from the stream.