按行读取文件 @param strFile
(String strFile)
| 36 | * @param strFile |
| 37 | */ |
| 38 | public static List<String> readFileByLine(String strFile) { |
| 39 | List<String> strList = new ArrayList<>(); |
| 40 | try { |
| 41 | File file = new File(strFile); |
| 42 | BufferedReader bufferedReader = new BufferedReader(new FileReader(file)); |
| 43 | String strLine = null; |
| 44 | int lineCount = 1; |
| 45 | while (null != (strLine = bufferedReader.readLine())) { |
| 46 | strList.add(strLine); |
| 47 | // log.info("第[" + lineCount + "]行数据:[" + strLine + "]"); |
| 48 | // System.out.println("第[" + lineCount + "]行数据:[" + strLine + "]"); |
| 49 | lineCount++; |
| 50 | } |
| 51 | } catch (Exception e) { |
| 52 | e.printStackTrace(); |
| 53 | } |
| 54 | return strList; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * 按行读取全部文件数据 |