title: How can I get my data from csv file to DataProvider
body: <p>I need to take data(username and password) from my csv.file and use it to register some new Users using DataProvider in Selenium. I have made already Reader to read this file but i can not put this data in DataProvider correctly. Help me please.</p>
  
  <p>I created a method for reading csv file and test with provider for working. </p>
  
  <p>my method
  public static List users = new ArrayList&lt;>();</p>
  
  <pre><code>public static Object openCSVReader() throws IOException {
  
      CSVReader reader = new CSVReader(new FileReader(System.getProperty("user.dir") + "\\src\\test\\resources\\users.csv"), ',');
  
      // read line by line
      String[] record = null;
  
      while ((record = reader.readNext()) != null) {
          User user = new User("username", "password");
          user.setUsername(record[0]);
          user.setPassword(record[1]);
          users.add(user);
      }
  
  
      reader.close();
      return users;
  
  }
  </code></pre>
  
  <p>my test</p>
  
  <pre><code>@Test(dataProvider = "registration")
      public void registerCSVFiles(String username, String password) throws IOException {
          registerPage.writeInForm(user);
          registerPage.writeFile(user);
          registerPage.selectUserAndRegister();
      }
  }
      @DataProvider(name = "registration")
      public static Object[][] credentials() throws IOException {
          return new Object[][]{
                  {users.get(0)},{users.get(1)}
          };
      }
  </code></pre>
  
  <p>I can not take data from my openCSVReader. Help pls</p>