request.getInputStream() 的两种解析方式
2024-09-06 14:11:44
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();
}
最新文章
- final修饰的变量是引用不能改变,还是引用的对象不能改变???
- ASP.NET的SEO--- Global.asax和HttpModule中的RewritePath()方法
- UVaLive 7500 Boxes and Balls (数学)
- SATA SAS SSD 硬盘介绍和评测
- struts2简介
- html = data.decode('gbk').encode('utf-8')
- spring 注解配置
- Eclipse知识
- 201521123118《java程序设计》第一周学习总结
- C#中结构体定义并转换字节数组
- <;转>;LOG日志级别
- Sublime Text 2激活、插件包安装、以及快捷键
- Linux上程序调试的基石(2)--GDB
- SpringBoot+Shiro+Redis共享Session入门小栗子
- Vux使用经验
- Python爬虫——你们要的王者荣耀高清图
- Centos7 安装PHP7版本及php-fpm,redis ,php-redis,hiredis,swoole 扩展安装
- CSS知识点集锦
- close Spark Streaming gratefully
- ZOJ2482 IP Address 2017-04-18 23:11 44人阅读 评论(0) 收藏