sql - How to validate (compare for sameness) two arraylists and output CSV file as results JAVA -


i have 2 arraylists (open working other collections) , need output csv file determines whether contents of these arraylists same; cell cell comparison essentially. arraylists taken result set , sorted. this:

sourcedata = (9, orlando, feb 28, 668, lloydtown, dec 1, etc)

targetdata = (9, caledon, jan 19, 38, south hark, dec 1, etc)

what attempted take first value of first arraylist, first value of second arraylist , compare them , print cvs file.

for (int = 0; <sizeofdata; i++) {    if (sourcedata.get(i).equals(targetdata.get(i))){         validator = ("true");     } else {         validator = ("false");     }     csvfileprinter.printrecord(sourcedata.get(i), targetdata.get(i), validator);    } 

the output looks desired:

9, 9, true 

however, need next row in csv file display:

 668, 38, false 

so overall pattern is:

 9, 9, true, orlando, caledon, false, feb 28, jan 19, false   668, 38, false, lloydtown, south hark, false, dec 1, dec 1, true 

where once put headers, , second column 'city', city values displayed in column 2.

i've tried every way write is, format of csv file wrong every time use csvfileprinter, writes next line. how write next column? when put want in 1 row array can make work, result sets going different every time cannot hardcode how many columns need. how can write across row, not down column when writing cvs file?

i don't see solution problem in of linked posts...

csvfileprinter.printrecord seems print complete record. in case, should outside loop. better refer, csvprinter can print iterable, can print arraylist , required solution below.

list<string> requiredoutput = new arraylist<>(); strin validator = "false"; (int = 0; <sizeofdata; i++) {    if (sourcedata.get(i).equals(targetdata.get(i))){         validator = ("true");     } else {         validator = ("false");     }     requiredoutput.add(sourcedata.get(i));     requiredoutput.add(targetdata.get(i));     requiredoutput.add(validator); } csvfileprinter.printrecord(requiredoutput); 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -