黑莓输入流到字符串的转换
如何在 BlackBerry 上将 InputStream 转换为字符串?
How do I convert an InputStream to a String on a BlackBerry?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何在 BlackBerry 上将 InputStream 转换为字符串?
How do I convert an InputStream to a String on a BlackBerry?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
Jonathan 的方法假设您的字节代表默认 BlackBerry 编码 (ISO-8859-1) 中的字符串。然而,大多数现代应用程序都是多语言的,因此支持的最佳编码是 UTF-8。为了尊重一组编码,你可以使用这样的东西:
Jonathan's approach assumes your bytes represent a String in default BlackBerry encoding (ISO-8859-1). However most modern apps are multy-languaged, so the best encoding to support is UTF-8. To respect a set encoding you may use smth like this:
我会将 inputStream 中的数据存储在 StringBuffer 中。代码如下所示:
I would store the data from the inputStream in a StringBuffer. The code would look like this:
对于最少的代码来说怎么样:
How about this for minimal code: