得到的InputStream 怎么样把他变成为String????(紧急等待)谢谢!!!!
其中各个inputstream很大的我是rst.getbinarystream(1)得到的
推荐阅读
据你所说,inputstream流入的东西很大,这有一个简单有效方法
java.io.bufferedreader br = new java.io.bufferedreader(new java.io.inputstreamreader(your inputstream here));
stringbuffer sb = new stringbuffer();
string temp;
while((temp=br.readline())!=null)
{
sb.append(temp);
}
sb.tostring()就是你要的字符串
注:未经调试!
public static string inputstreamtostring(inputstream is) throws
customexception {
bufferedinputstream bis = new bufferedinputstream(is, 1024);
datainputstream dis = new datainputstream(bis);
stringbuffer buffer = new stringbuffer();
try {
try {
int ch;
for (; ; ) {
ch = dis.readchar();
buffer.append( (char) ch);
}
}
catch (eofexception e) {
dis.close();
return buffer.tostring();
}
catch (ioexception e) {
throw new customexception(e.getmessage());
}
}
catch (ioexception e) {
throw new customexception(e.getmessage());
}
}


讨论区