本文介绍了BufferedInputStream到字符串转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将此BufferedInputStream放入我的字符串中,该怎么做?
Hi I want to put this BufferedInputStream into my string how can I do this?
BufferedInputStream in = new BufferedInputStream(sktClient.getInputStream() );
String a= in.read();
推荐答案
BufferedInputStream in = new BufferedInputStream(sktClient.getInputStream());
byte[] contents = new byte[1024];
int bytesRead = 0;
String strFileContents;
while((bytesRead = in.read(contents)) != -1) {
strFileContents += new String(contents, 0, bytesRead);
}
System.out.print(strFileContents);
这篇关于BufferedInputStream到字符串转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!