public void tempImportJumpLog(String filePath){ File file = new File(filePath); try { BufferedInputStream fis = new BufferedInputStream(new FileInputStream(file)); // 用5M的缓冲读取文本文件 BufferedReader reader = new BufferedReader(new InputStreamReader(fis,"utf-8"),5*1024*1024); String line = ""; int i=1; while((line = reader.readLine()) != null){ //TODO: write your business if(StringUtils.isNotEmpty(line)){ kafkaTemplate.send("data-monitor", line); }else{ } i++; System.out.println("send msg to kafka:"+i); } } catch (Exception e) { e.printStackTrace(); } }



还没有评论,来说两句吧...