获取SD卡上的文档的内容
2015-10-20 21:03
134 查看
思路:把文件流输入流转化成字符串
1. fileInputStream
1. fileInputStream
InputStream inputStream = null; try { inputStream = new FileInputStream(Environment.getExternalStorageDirectory()+"/c360_debug.txt"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } Toast.makeText(getApplicationContext(), getStreamString(inputStream), 1).show();2.把输入流转化成一个字符串
/** * 将一个输入流转化为字符串 */ public static String getStreamString(InputStream tInputStream) { if (tInputStream != null) { try { BufferedReader tBufferedReader = new BufferedReader( new InputStreamReader(tInputStream)); StringBuffer tStringBuffer = new StringBuffer(); String sTempOneLine = new String(""); while ((sTempOneLine = tBufferedReader.readLine()) != null) { tStringBuffer.append(sTempOneLine); } return tStringBuffer.toString(); } catch (Exception ex) { ex.printStackTrace(); } } return null; }
相关文章推荐
- 南阳热省赛A——找规律——Googol String
- 排队(BZOJ1731:[Usaco2005 dec]Layout 排队布局)
- OS X 10.11 中的安全删除文件
- 高斯模糊效果实现方案及性能对比
- OS X 10.11 中的安全删除文件
- OS X 10.11 中的安全删除文件
- tinyxml 查找element
- DOM对象
- Android报表解决方案 使用开源组件iChartjs(二)
- Win10与Ubuntu 15.04双系统安装方法
- LintCode-最大数
- 菜鸟之路-04
- Android中layout_align****和setPadding方法整合
- HDU 1428 漫步校园(Spfa+记忆化搜索)
- 日经春秋 20151020
- 反射了解集合泛型的本质
- Android报表解决方案 使用开源组件iChartjs(一)
- POJ 3617 Best Cow Line(字典序最小问题)
- P1004 滑雪
- svn冲突问题详解 SVN版本冲突解决详解