You can specify the download location. Below code might help you try it
File file = new File("./downloads");
boolean b = false;
if (!file.exists()) {
b = file.mkdirs();
}
FileUtils.cleanDirectory(file);
String downloadFolder = System.getProperty("user.dir")+"/downloads";
if (browser.equalsIgnoreCase("Chrome")) {
HashMap<String, Object> chromePref = new HashMap<>();
chromePref.put("download.default_directory", downloadFolder);
chromePref.put("download.prompt_for_download", "false");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromePref);
driver = new ChromeDriver(options);
} else if (browser.equalsIgnoreCase("Firefox")) {
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.dir",downloadFolder ); // folder
profile.setPreference("pdfjs.disabled", true); // disable the built-in viewer
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.panel.shown", false);
profile.setPreference("browser.helperApps.neverAsksaveToDisk", "application/x-msexcel,application/excel,application/x-excel,application/excel,application/x-excel,application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setCapability(FirefoxDriver.PROFILE, profile);
firefoxOptions.setCapability(FirefoxDriver.MARIONETTE, true);
firefoxOptions.setCapability(CapabilityType.ELEMENT_SCROLL_BEHAVIOR, 0);
driver = new FirefoxDriver(firefoxOptions);
}