Want to compare two csv files in java and want to have the complete details removed of one csv file from the other by comparing the 1st column :          public class CompareCSV {
         public static void main(String args[]) throws FileNotFoundException, IOException
        {
        String path="C:\\csv\\";
        String file1="file1.csv";
        String file2="file2.csv";
        String file3="file3.csv";
        ArrayList<String> al1=new ArrayList<String>();
        ArrayList<String> al2=new ArrayList<String>();
        
        BufferedReader CSVFile1 = new BufferedReader(new FileReader("/C:/Users/bida0916/Desktop/macro.csv"));
        String dataRow1 = CSVFile1.readLine();
        while (dataRow1 != null)
        {
            String[] dataArray1 = dataRow1.split(",");
            for (String item1:dataArray1)
            { 
               al1.add(item1);
            }
            
            dataRow1 = CSVFile1.readLine(); 
        }
        
         CSVFile1.close();
         
        BufferedReader CSVFile2 = new BufferedReader(new FileReader("C:/Users/bida0916/Desktop/Deprecated.csv"));
        String dataRow2 = CSVFile2.readLine();
        while (dataRow2 != null)
        {
            String[] dataArray2 = dataRow2.split(",");
            for (String item2:dataArray2)
            { 
               al2.add(item2);
               
            }
            dataRow2 = CSVFile2.readLine(); 
        }
         CSVFile2.close();
         
         for(String bs:al2)
         {
             al1.remove(bs);
         }
         
         int size=al1.size();
         System.out.println(size);
         
         try
            {
                FileWriter writer=new FileWriter("C:/Users/bida0916/Desktop/NewMacro.csv");
                while(size!=0)
                {
                    size--;
                    writer.append(""+al1.get(size));
                    writer.append('\n');
                }
                writer.flush();
                writer.close();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
    }
}


I want to compare two csv files in java and want to have the complete details removed of one csv file from the other by comparing the first column of both the files. Currently I am getting a csv file with one column only having all details jumbled up.