将 InputStream 转换为 Stream<String>给定一个字符集 [英] Convert InputStream into Stream<String> given a Charset

查看:39
本文介绍了将 InputStream 转换为 Stream<String>给定一个字符集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 InputStream is 转换为 Stream<String>以 streamis 行组成的方式给定 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();

这篇关于将 InputStream 转换为 Stream&lt;String&gt;给定一个字符集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆