Downloading the files in headless chrome

Hi

I want to download the file in headless chrome.
I’m Using the below code:

HashMap<Object, String> chromePrefs = new HashMap<Object, String>()
chromePrefs.put(“download.default_directory”, RunConfiguration.getProjectDir() + “/Include/TestData/DownloadedFiles”)
chromePrefs.put(“browser.setDownloadBehavior”, “allow”)
RunConfiguration.setWebDriverPreferencesProperty(“prefs”, chromePrefs)

But it’s not working,Is there anyway to accomplish this?