In this post I see the solutions for setting the download directories for Chrome and Firefox how to change file download location in Webdriver while using chrome driver/firefox
I am changing default directory by changing REGEDIT.
String path = "\"C:\\Test\"";
String cmd1 = "REG ADD \"HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main\" /F /V \"Default Download Directory\" /T REG_SZ /D "+ path;
try {
Runtime.getRuntime().exec(cmd1);
} catch (Exception e) {
System.out.println("Coulnd't change the registry for default directory for IE");
}