小编Ala*_*ska的帖子

如何以Java 8方式在特定URL上获取文本行?

我想逐行阅读这些文字:http://www.puzzlers.org/pub/wordlists/unixdict.txt

我试图得到一个流:

Stream<String> stream = Files.lines(Paths.get("http://www.puzzlers.org/pub/wordlists/unixdict.txt"));
stream.forEach((word) -> System.out.println(word));
//Close the stream and it's underlying file as well
stream.close();
Run Code Online (Sandbox Code Playgroud)

但我怀疑它只适用于文件.是否有类似的URL方法?

java java-8 java-stream

6
推荐指数
1
解决办法
3723
查看次数

标签 统计

java ×1

java-8 ×1

java-stream ×1