public class Downloader
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkMD5OfFile(java.lang.String targetMD5,
java.io.File file)
Check the MD5 of the specified file
|
static void |
download(java.lang.String name,
java.net.URL url,
java.io.File f,
java.lang.String targetMD5,
int maxTries)
Download the specified URL to the specified file, and verify that the target MD5 matches
|
static void |
downloadAndExtract(java.lang.String name,
java.net.URL url,
java.io.File f,
java.io.File extractToDir,
java.lang.String targetMD5,
int maxTries)
Download the specified URL to the specified file, verify that the MD5 matches, and then extract it to the specified directory.
Note that the file must be an archive, with the correct file extension: .zip, .jar, .tar.gz, .tgz or .gz |
public static void download(java.lang.String name,
java.net.URL url,
java.io.File f,
java.lang.String targetMD5,
int maxTries)
throws java.io.IOException
name - Name (mainly for providing useful exceptions)url - URL to downloadf - Destination filetargetMD5 - Expected MD5 for filemaxTries - Maximum number of download attempts before failing and throwing an exceptionjava.io.IOException - If an error occurs during downloadingpublic static void downloadAndExtract(java.lang.String name,
java.net.URL url,
java.io.File f,
java.io.File extractToDir,
java.lang.String targetMD5,
int maxTries)
throws java.io.IOException
name - Name (mainly for providing useful exceptions)url - URL to downloadf - Destination fileextractToDir - Destination directory to extract all filestargetMD5 - Expected MD5 for filemaxTries - Maximum number of download attempts before failing and throwing an exceptionjava.io.IOException - If an error occurs during downloadingpublic static boolean checkMD5OfFile(java.lang.String targetMD5,
java.io.File file)
throws java.io.IOException
targetMD5 - Expected MD5file - File to checkjava.io.IOExceptionCopyright © 2019. All rights reserved.