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文本文件
最新推荐文章于 2024-08-31 10:35:17 发布