title: Java: check CSV file on duplicate lines using ArrayList
body: <p>I have a CSV file with this content:</p>
  <p><code>2017-10-29 00:00:00.0,&quot;1005&quot;,-10227,0,0,0,332894,0,0,222,332894,222,332894 2017-10-29 00:00:00.0,&quot;1010&quot;,-125529,0,0,0,420743,0,0,256,420743,256,420743 2017-10-29 00:00:00.0,&quot;1005&quot;,-10227,0,0,0,332894,0,0,222,332894,222,332894 2017-10-29 00:00:00.0,&quot;1013&quot;,-10625,0,0,-687,599098,0,0,379,599098,379,599098 2017-10-29 00:00:00.0,&quot;1604&quot;,-1794.9,0,0,-3.99,4081.07,0,0,361,4081.07,361,4081.07</code></p>
  <p>So lines 1 and 3 are duplicates.
  Now I want to read the file in and print out duplicate lines in the console.</p>
  <p>I set up this Java code reading the file in and throwing it line by line into an ArrayList. Then I create an immutable
  copy, loop through the ArrayList and in the binarySearch I use the immutable copy of the ArrayList:</p>
  <pre><code>import java.io.BufferedReader;
  import java.io.FileNotFoundException;
  import java.io.FileReader;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.List;
  
  public class ReadValidationFile {
  
  public static void main(String[] args) {
  
      List&lt;String&gt; validationFile = new ArrayList&lt;&gt;();
  
      try(BufferedReader br = new BufferedReader(new FileReader(&quot;validation_small.csv&quot;));){
  
          String line;
          while((line = br.readLine())!= null){
              validationFile.add(line);
          }
  
      } catch (FileNotFoundException e) {
          //e.printStackTrace();
          System.out.println(&quot;file not found &quot; + e.getMessage());
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      List&lt;String&gt; validationFileCopy = Collections.unmodifiableList(validationFile);
  
      for(String line : validationFile){
          int comp = Collections.binarySearch(validationFileCopy,line,new ComparatorLine());
          if (comp &lt;= 0){
              System.out.println(line);
          }
  
      }
  }
  }
  </code></pre>
  <p>Comparator Class:</p>
  <pre><code>import java.util.Comparator;
  
  public class ComparatorLine implements Comparator&lt;String&gt; {
  @Override
  public int compare(String s1, String s2) {
      return s1.compareToIgnoreCase(s2);
  }
  }
  </code></pre>
  <p>I expect this line to be printed:</p>
  <pre><code>2017-10-29 00:00:00.0,&quot;1005&quot;,-10227,0,0,0,332894,0,0,222,332894,222,332894
  </code></pre>
  <p>But the output I get is this:</p>
  <pre><code>2017-10-29 00:00:00.0,&quot;1010&quot;,-125529,0,0,0,420743,0,0,256,420743,256,420743
  </code></pre>
  <p>Can you help me please to see what I am doing wrong? My comparator I think is okay. What is wrong with my
  ArrayLists?</p>