黑莓的InputStream字符串转换 [英] BlackBerry InputStream to String conversion

查看:120
本文介绍了黑莓的InputStream字符串转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何把一个InputStream为String在BlackBerry?

How do I convert an InputStream to a String on a BlackBerry?

推荐答案

我想从InputStream在一个StringBuffer存储数据。在code是这样的:

I would store the data from the inputStream in a StringBuffer. The code would look like this:

byte[] buffer = new byte[1024];
StringBuffer sb = new StringBuffer();
int readIn = 0;
while((readIn = inputStream.read(buffer)) > 0)
{
     String temp = new String(buffer, 0, readIn);
     sb.append(temp);  
}
String result = sb.toString();

这篇关于黑莓的InputStream字符串转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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