这个问题已经在这里有了答案:
9年前关闭。
嗨,我想将此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);