文件内容格式:

string1

string2

String 3

……

很简单,两句话

String content = new String(Files.readAllBytes(Paths.get(".\\src\\main\\resources\\content")));
List<String> sequences = Arrays.asList(content.split("\r\n"));

还有一个办法,相对啰嗦一点:

  String path= ".\\src\\main\\resources\\content";

  BufferedReader contentbr = new BufferedReader(new FileReader(path));
  String line = "";

  List<String> contentString= new ArrayList<>();
  while ((line = contentbr.readLine()) != null) {
   contentString.add(line);

  }

  return contentString;

 

相关文章:

  • 2021-11-28
  • 2022-12-23
  • 2021-06-01
  • 2021-05-18
  • 2022-12-23
  • 2021-09-03
  • 2021-09-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
相关资源
相似解决方案