public static List<String> readCsv(String path) { List<String> list = new ArrayList<>(); InputStream ins = null; BufferedReader reader = null; try { Resource resource = new ClassPathResource(path); ins = resource.getInputStream(); reader = new BufferedReader(new InputStreamReader(ins, "UTF-8")); String line = ""; while ((line = reader.readLine()) != null) { list.add(line); } } catch (Exception e) { } finally { try { if (reader != null) { reader.close(); reader = null; } if (ins != null) { ins.close(); ins = null; } } catch (IOException e) { } } return list; }
springboot 讀取resources文本文件
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.