title: How do you compare values in a database and a flat file in Java?
body: <p>I have a flat file that is pipe delimited and an database table.  I would like to create a 2nd flat file that contains all the differences between the flat file and the database.</p>
  
  <p>An example would be if there exists entries in the database that do not exist in the flat file the entire row would be printed in the 2nd flat file (there will never be an entry in the flat file that is not in the database).  Another example would be if the rows are similar but there is a difference in a field then the database entry would be printed in the flat file.</p>
  
  <p>The best way I can think to do this is to create 2 two-dimensional arrays containing the data from the flat file and the database, if the primary key does not exist in the flat file array then print out the results from a select statement.  If the primary key does exist but the other fields do not exist then print out the results from a select statement.  This is the best thing i can think of, however it seems inefficient.</p>
  
  <p>Is there a better way to do this?  I am using Java to do this.</p>