将流转化为字符串的方法
来源:互联网 发布:淘宝网 桌子 编辑:程序博客网 时间:2024/04/29 20:21
public class StreamTools {
public static String readStream(InputStream is){
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = -1;
while((len = is.read(buffer)) != -1){
baos.write(buffer, 0, len);
}
is.close();
return new String(baos.toByteArray());
} catch (Exception e) {
return "";
}
}
}
public static String readStream(InputStream is){
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = -1;
while((len = is.read(buffer)) != -1){
baos.write(buffer, 0, len);
}
is.close();
return new String(baos.toByteArray());
} catch (Exception e) {
return "";
}
}
}
0 0
- 将流转化为字符串的方法
- 将流转化为字符串
- 把流转化为字符串
- 将Http请求输入流转化为字符串工具类StreamHelper
- Java将流转化为文件
- 把流转化为字符串String类型的工具类
- 将流转换成字符串
- 字节流转换为字符串的方法
- 字节流转换为字符串的方法
- C# 将bit流转化为十六进制显示出来
- 如何将网络流转化为内存流 C#
- 将数据流转化为图片 并显示在前台页面
- 将输入流转为字符串
- 将InputStream流转换成字符串
- java将流转换成字符串
- 将输入流转换成字符串
- 将已赋值的字符串初始化为空
- C# 将字节流转换为图片的实例方法
- 周末,有一起爬山的吗
- spring在ssh框架中到底起到什么作用
- linux一次性定时任务
- 开启新篇章 新博客正式开通
- Vanya and Computer Game
- 将流转化为字符串的方法
- VS2013如何添加LIb库及头文件的步骤
- Android 如何永久性开启adb 的root权限
- win7下硬盘安装CentOs7
- 索引截断技术
- 【高斯消元】【poj 2065】SETI
- EditPlus的nesc模板文件
- centos 安装testlink出现:You don't have permission to access /testlink on this server
- Perl 脚本中单元测试