title: How to compare data of two CSV files in java (row by row)
body: <p>I am working on a java project where i have to compare two CSV files. First program should read the data form every column and compare it with all other column's. </p>
  
  <p>CSVFILE1 has 3 column's </p>
  
  <pre><code>name , organization , preference   
  </code></pre>
  
  <p>CSVFILE2 has 3 column's </p>
  
  <pre><code>name , organization , preference . 
  </code></pre>
  
  <p>If both file has same values in all the 3 of the column's then program should return true . If not I have to check in 3rd column and make changes to CSVFILE2 . </p>
  
  <p>Presently I have made method where I can read CSVFILE'S and assign to an array. Below is my code.</p>
  
  <pre><code>import java.awt.List;
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Scanner;
  
  public class Hospetal {
      static String file1Path1 = "C:\\\\Users\\\\DANGER\\\\Desktop\\\\New folder\\\\Diva.csv";
  
      public static void main(String[] args) throws IOException {
          ReadFirstFile();
  
      }
  
      //Reading file form csv
      public static void ReadFirstFile() throws FileNotFoundException {
          String token1 = "";
          Scanner inFile1 = new Scanner(new File(file1Path1)).useDelimiter(",\\s*");
          ArrayList&lt;String&gt; temps = new ArrayList&lt;String&gt;();
  
          // while loop
          while (inFile1.hasNext()) {
              // find next line
              token1 = inFile1.next();
              temps.add(token1);
          }
  
          inFile1.close();
  
          String[] tempsArray = temps.toArray(new String[0]);
  
          for (String s : tempsArray) {
              System.out.println(s);
          }
      }
  }
  </code></pre>