BufferedInputStream到字符串转换?
问题内容:
嗨,我想将此BufferedInputStream放入我的字符串中,我该怎么做?
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);