title: how to download a file inside Java project's resource directory
body: <p>I have a scenario where I click on download link in my app and it downloads an excel sheet in my local drive. I am using selenium webdriver to automate and validate if file has in fact downloaded. I am able to download file and validate its presence in local file system. But how do I make webdriver download file in the resource directory of my project.</p>
  
  <p>This is what I am doing now:</p>
  
  <pre><code>System.setProperty("webdriver.chrome.driver", Constants.Chrome_Driver_Path_Win);
              HashMap&lt;String, Object&gt; chromePrefs = new HashMap&lt;String, Object&gt;();
              chromePrefs.put("profile.default_content_settings.popups", 0);
              chromePrefs.put("download.default_directory", "C:\\pixeldownload");
              ChromeOptions options = new ChromeOptions();
              options.setExperimentalOption("prefs", chromePrefs);
              DesiredCapabilities cap = DesiredCapabilities.chrome();
              cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
              cap.setCapability(ChromeOptions.CAPABILITY, options);
              driver = new ChromeDriver(cap);
  </code></pre>
  
  <p>Right now I am hardcoding  "C:\pixeldownload" but I want to put the file into "resource" folder inside my java project.</p>
  
  <p>chromePrefs.put("download.default_directory", "resource"). Putting destination as "resource" is not helping me. How do i download file inside "resource" directory.</p>
  
  <pre><code>public boolean isFileDownloaded(String downloadPath,String fileName) {
          boolean flag = false;
          File dir = new File(System.getProperty("user.dir") + "\\resources\\downloads");
          File[] dir_contents = dir.listFiles();
          for (int i = 0; i &lt; dir_contents.length; i++) {
              if (dir_contents[0].getName().contains(fileName))   
                  return flag=true;   
                  }
          return flag;
      }
  </code></pre>