Class FileDownloader

java.lang.Object
org.naviqore.utils.network.FileDownloader

public final class FileDownloader extends Object
Downloading files from a specified URL. Ensures that the directory exists before downloading and provides an option to overwrite existing files.
  • Constructor Details

    • FileDownloader

      public FileDownloader(String url)
      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 to
      fileName - the name of the file to be saved
      overwrite - whether to overwrite the file if it already exists
      Throws:
      IOException - if an I/O error occurs
      InterruptedException - if the download is interrupted