缓冲输入流到字符串的转换?
2022-08-31 13:51:04
可能的重复:
在Java中,如何将输入流读取/转换为字符串?
嗨,我想将此缓冲输入流转换为我的字符串。我该怎么做?
BufferedInputStream in = new BufferedInputStream(sktClient.getInputStream() );
String a= in.read();
可能的重复:
在Java中,如何将输入流读取/转换为字符串?
嗨,我想将此缓冲输入流转换为我的字符串。我该怎么做?
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);