您的位置:首页 > 产品设计 > UI/UE

request.getInputStream() 的两种解析方式

2017-03-16 18:54 381 查看
http://sagewsg.iteye.com/blog/1717923

byte[] bytes = new byte[1024 * 1024];
InputStream is;
try {
is = request.getInputStream();
int nRead = 1;
int nTotalRead = 0;
while (nRead > 0) {
nRead = is.read(bytes, nTotalRead, bytes.length - nTotalRead);
if (nRead > 0)
nTotalRead = nTotalRead + nRead;
}
String str = new String(bytes, 0, nTotalRead, "utf-8");
System.out.println("Str:" + str);
res = str;
is.close();
is = null;
} catch (IOException e) {
e.printStackTrace();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: