代码语言:javascript复制
public static String getStreamAsString(InputStream stream, String charset) throws IOException {
try {
Reader reader = new InputStreamReader(stream, charset);
StringBuilder response = new StringBuilder();
char[] buff = new char[1024];
int read;
while((read = reader.read(buff)) > 0) {
response.append(buff, 0, read);
}
String var6 = response.toString();
return var6;
} finally {
if (stream != null) {
stream.close();
}
}
}
代码语言:javascript复制String body = WebUtils.getStreamAsString(request.getInputStream(), charset);
参考com.taobao.api.internal.util.WebUtils#getStreamAsString