将 InputStream 转换为 Stream<String>给定一个字符集
我想将 InputStream is 转换为 Stream<String>以 stream 由 is 行组成的方式给定 Charset cs.此外,一行 is 不应立即读取,而应仅在 stream 需要时读取.
I want to convert an InputStream is into a Stream<String> stream given a Charset cs in such a way that stream consists of the lines of is. Furthermore a line of is should not be read immediately but only in case stream needs it.
推荐答案
我觉得你可以试试:
Stream<String> lines = new BufferedReader(new InputStreamReader(is, cs)).lines();
相关文章