code: public static long copy(URL url, File baseDir, String fileName) throws FileNotFoundException, IOException, IllegalArgumentException
    {
      Params.notNull(url, "Source URL");
      URLConnection connection = url.openConnection();
      connection.setDoInput(true);
      // copy method takes care to close both streams so there is no need to handle here URL connection close
      return copy(connection.getInputStream(), new FileOutputStream(new File(baseDir, fileName)));
    }
docs: Copy remote binary file denoted by requested URL to local file identified by given base directory and file name.
  Local file is created by {@link File#File(File, String)}. This method creates local file if it does already exist.
  
  @param url remote file URL,
  @param baseDir local file base directory,
  @param fileName local file name.
  @return the number of bytes transfered.
  @throws FileNotFoundException if given local file does not exist and cannot be created.
  @throws IOException if transfer fails.
  @throws IllegalArgumentException if <code>url</code> is null.