title: How to provide property file name dynamically in java
body: <p>Hi I am using two property files. one is for application configuration and another one is for object repository. I am going to use these two properties through out my application. for each and every testcase I am initialising property and access the files using property object. But I want to initialise property in a separate method in separate class.Also I want to call the method in another class and access the property files using that initialised property object. I don't know how to do this. Please give me a hand for this task to be done.Thanks in advance</p>
  
  <p><strong>Below is my code</strong></p>
  
  <pre><code>public class PropertiesExample {
  
      public static void main(String[] args) {
  
          WebDriver driver = null;
          String baseUrl;
          File file = new File("/home/vaav/workspace/PropertiesExample/config.properties");
          Properties prop = new Properties();
          FileInputStream fileIO = null;
  
          try{
              fileIO = new FileInputStream(file);
              prop.load(fileIO);
              fileIO.close();
          }catch(FileNotFoundException ex){
              ex.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          System.setProperty("webdriver.chrome.driver", "/home/vaav/workspace/PropertiesExample/lib/chromedriver");
          driver = new ChromeDriver();
          baseUrl = prop.getProperty("URL");
          driver.get(baseUrl+"/");
  
          driver.manage().window().maximize();
          driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
          driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  
          driver.findElement(By.xpath(prop.getProperty("Login.btnAdmin"))).click();
          driver.findElement(By.id(prop.getProperty("Login.txtUsername"))).sendKeys(prop.getProperty("userName"));
          driver.findElement(By.id(prop.getProperty("Login.txtPassword"))).sendKeys(prop.getProperty("password"));
          driver.findElement(By.id(prop.getProperty("Login.btnSignIn"))).click();
      }
  
  }
  </code></pre>
  
  <p>I want to do the property related stuff in another file and make reusability of that code</p>