設定
ファイル(text.txt)の中身
apple
bear
picnic
...
方法
方法1
List<String> words = java.nio.file.Files
.lines(Paths.get(getClass().getResource("/text.txt").toURI()))
.collect(Collectors.toList());
しかし、Jarファイル内のファイルが読み込めない(FileSystemNotFoundException)
方法2
List<String> words = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/text.txt")))
.lines().collect(Collectors.toList());