Tag: equals code uses element delete to perform dev repeat hash
To insert into the database go to weight:
1. Iterate through the list you have read
2. Get the data you need to query before you insert the method into the database, execute the Query method
1 devlist=devicedao.finddevice (Device.getrfid ()); 2 if (Devlist.size () >0) {3 messagestr = "Duplicate data, please re-import!" "; 4 5 } Else {6 devicedao.save (device); 7 MESSAGESTR = "Data import successful!" "; 8 }
To the imported Excel file to go to the weight:
(1) The elements in the loop list are deleted repeatedly
1 //devlist for cyclic reading2 for(inti = 0; I < Devlist.size ()-1; i + + ) { 3 for(intj = devlist.size ()-1; J > i; J-- ) { 4 if(Devlist.get (j). Equals (Devlist.get (i))) {5 Devlist.remove (j); 6 } 7 } 8}
(2) Remove duplicate elements by HashSet
1 // as above, list is the list for getting to Excel data 2 New HashSet (list); 3 list.clear (); 4 List.addall (h);
(3) Traverse list to see if the data exists and use contain
1 New ArrayList (); 2 for (int i=0;i<list.size (); i++) { 3 if(! Listtemp.contains (List.get (i))) { 4 listtemp.add (list.get (i )); 5 } 6 }
About importing data to Excel and deduplication the database and the imported Excel file