将InputStream(输入流)转成String 的方法
2015-08-03 23:33
387 查看
public static String readInputStream(FileInputStream inStream) { try { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int length = -1; while ((length = inStream.read(buffer)) != -1) { outStream.write(buffer, 0, length); } outStream.close(); inStream.close(); return outStream.toString(); } catch (IOException e) { Log.i("FileTest", e.getMessage()); } return null; }
相关文章推荐
- 学习指针型函数和指向函数的指针
- 前五天知识点总结
- 通俗理解TCP握手次数是三次
- 一个例子读懂风险投资
- 一个例子读懂风险投资
- 一个例子读懂风险投资
- JS之原型与原型链
- java 枚举类小结 Enum
- jQuery选择器总结
- hdu 1166 敌兵布阵
- js时间间隔和倒计时
- 数据结构之链表、栈和队列 java代码实现
- IOS绘图API绘制直线几何图形
- Oracle笔记-表的管理
- Android利用Binder类实现对服务的调用
- dom4j将xml转换成对象
- 父类不含无参构造方法子类构造方法必须显式调用
- Delphi二维码中文支持、分组、批量打印经验小结
- 递归
- 【LeetCode】198 - House Robber