List of Map traversal value

实现思路:

List list = new ArrayList(); Map map = new HashMap();
for(i=0;i<list.size;i++){   map=list.get(i);   for (String key : map.keySet()){   System.out.println("key:"+key+",value:"+map.get(key) );   } }
Project uses:

Package Penalty for com.ilotterytech.bwlbis.warehouse.imports.service; Import java.io.IOException; Import java.util.List; Import java.util.Map;
/ * * * @ Author: zhukaixin * @ a Date: 2019 -06-05-15: 36 * @ Asc: cashing i.e. billing data query * / @Service @Transactional public class RedemptionDataInquiryService the extends DefaultRestService <RedemptionDataInquiry, Long, RedemptionDataInquiryRepository> { / * * * i.e. billing data query data lead cashing * * @ MultipartFile param * @return * @throws IOException * / public HtmlResult saveFileImport(MultipartFile multipartFile) throws IOException { FileReader result = new FileReader(multipartFile.getInputStream(), multipartFile.getOriginalFilename()); ExcelTitleReader excelTitleReader = new ExcelTitleReader(this.getClass().getClassLoader().getResourceAsStream("/res/RedemptionDataInquiry.properties")); //处理返回结果 HtmlResult htmlResult = result.read().asHtmlResult(excelTitleReader); List<Map<String, Object>> contents = htmlResult.getContents(); for (int= I 0 ; I <contents.size (); I ++ ) { the Map <String, Object> m = Contents. GET (I); // get the first Map, because it is ArrayList, so that the first subscript 0 redemptionDataInquiry = redemptionDataInquiry new new redemptionDataInquiry (); for (E of Map.Entry: m.entrySet ()) { // iterate the Map IF (. e.getKey () the equals ( " DATE " )) { redemptionDataInquiry.setDate (String.valueOf ( e.getValue ())); } the else IF (e.getKey () the equals (. " District " )) { redemptionDataInquiry.setDistrict(String.valueOf(e.getValue())); }else if (e.getKey().equals("stationCode")) { redemptionDataInquiry.setStationCode(String.valueOf(e.getValue())); }else if (e.getKey().equals("generate")) { redemptionDataInquiry.setGenerate(String.valueOf(e.getValue())); } else if (e.getKey().equals("gameName")) { redemptionDataInquiry.setGameName(String.valueOf(e.getValue())); }else if (e.getKey().equals("gameCode")) { redemptionDataInquiry.setGameCode(String.valueOf(e.getValue())); }else if (e.getKey().equals("money")) { redemptionDataInquiry.setMoney(String.valueOf(e.getValue())); }else if (e.getKey().equals("redemptionCommission")) { redemptionDataInquiry.setRedemptionCommission(String.valueOf(e.getValue())); } } save(redemptionDataInquiry); } return htmlResult; } }

 

Guess you like

Origin www.cnblogs.com/zhukaixin/p/10985962.html