读取TEXT文件数据
@Override @Transactional(rollbackFor = Exception.class) public Result<?> read() { List<String> textList = ReadFileCon("D:\\11.csv"); for(String content : textList){ List<String> text = Arrays.asList(content.split(",")); FirmDTO dto = new FirmDTO(); dto.setBaseName(text.get(0)); dto.setBaseAddress(text.get(1)); dto.setBaseStatus(true); dto.setChargePersonName(text.get(2)); dto.setLegalPerson(text.get(2)); dto.setChargePersonPhone(text.get(3)); dto.setContactNumber(text.get(3)); dto.setLat("0"); dto.setLon("0"); //pcAdd(dto); } return Result.ok("11"); } private List<String> ReadFileCon(String filePathName){ List<String> strList = new ArrayList<>(); BufferedReader reader; try { reader = new BufferedReader(new FileReader(filePathName)); String line = reader.readLine(); while (line != null) { strList.add(line); line = reader.readLine();// 继续读取下一行 } reader.close(); return strList; } catch (Exception e) { e.printStackTrace(); System.out.println("文件不存在"); return strList; } }
标签:文件,dto,读取,get,text,new,reader,操作,strList From: https://www.cnblogs.com/lewisat/p/18096360