从InputStream中读取文本 [英] Read text from InputStream

查看:122
本文介绍了从InputStream中读取文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我从java.io.InputStream开始,那么将整个流读入字符串的最简单方法是什么(假设是utf-8)?

If I start with a java.io.InputStream, what's the easiest way to read the entire stream out into a String (assuming utf-8)?

这个应该很容易,但我主要是一个C#人,谷歌在这方面让我失望。谢谢。

This should be pretty easy but I'm mostly a C# person and google is failing me on this. Thanks.

推荐答案

根据您所熟悉的许可证,它是 one liner

Depending on what licenses you are comfortable with, it's a one liner with Jakarta-Commons IO library.

这篇关于从InputStream中读取文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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