Package org.naviqore.utils.network
Class FileDownloader
java.lang.Object
org.naviqore.utils.network.FileDownloader
Downloading files from a specified URL. Ensures that the directory exists before downloading and provides an option
to overwrite existing files.
-
Constructor Summary
ConstructorsConstructorDescriptionFileDownloader(String url) Constructs a new FileDownloader for the specified URL. -
Method Summary
Modifier and TypeMethodDescriptionvoiddownloadTo(Path directory, String fileName, boolean overwrite) Downloads a file to the specified directory with the given file name.
-
Constructor Details
-
FileDownloader
Constructs a new FileDownloader for the specified URL.- Parameters:
url- the URL to download the file from
-
-
Method Details
-
downloadTo
public void downloadTo(Path directory, String fileName, boolean overwrite) throws IOException, InterruptedException Downloads a file to the specified directory with the given file name. If the file already exists, it will be overwritten if the overwrite parameter is true. Ensures that the directory exists before downloading.- Parameters:
directory- the directory to download the file tofileName- the name of the file to be savedoverwrite- whether to overwrite the file if it already exists- Throws:
IOException- if an I/O error occursInterruptedException- if the download is interrupted
-