BufferedReaderalso has a method lines()that returns a stream. So you just need to open the BufferedReader, which wraps the InputStreamReader, wrapping the URL connection input stream:
try (InputStream is = new URL("http://www.puzzlers.org/pub/wordlists/unixdict.txt").openConnection().getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
Stream<String> stream = reader.lines()) {
stream.forEach(System.out::println);
}
source
share