Possible Duplicate:
In Java how do a read/convert an InputStream in to a string?
您好,我想将此 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);
关于java - BufferedInputStream 到字符串的转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5713857/