android 读写文本
来源:互联网 发布:有生日提醒软件 编辑:程序博客网 时间:2024/06/06 04:09
1、从resources中的raw 文件夹中获取文件并读取数据
public String getFromRaw(int raw){ String result = ""; try { InputStream in = getResources().openRawResource(raw); //获取文件的字节数 int lenght = in.available(); //创建byte数组 byte[] buffer = new byte[lenght]; //将文件中的数据读到byte数组中 in.read(buffer); result = EncodingUtils.getString(buffer, ENCODING); } catch (Exception e) { e.printStackTrace(); } return result; }
2、从assets 文件夹中获取文件并读取数据
public String getFromAssets(String fileName){ String result = ""; try { InputStream in = getResources().getAssets().open(fileName); //获取文件的字节数 int lenght = in.available(); //创建byte数组 byte[] buffer = new byte[lenght]; //将文件中的数据读到byte数组中 in.read(buffer); result = EncodingUtils.getString(buffer, ENCODING); } catch (Exception e) { e.printStackTrace(); } return result; }
- android 读写文本
- 读写文本
- 读写文本
- 文本读写
- 读写文本的类
- C#读写文本
- evc 读写文本问题
- C++ 文本读写
- vb.net读写文本
- 文本的读写java
- C++读写文本
- c#文本读写
- C++读写unicode文本
- python 文本读写操作
- 文本的读写
- 文本的读写
- RandomAccessFile 文本随机读写
- java简单读写文本
- 内核驱动模块编译方法
- zoj 1232(Floyd预处理 + 状态图上的最短路(好题))
- Singleton模式
- Ubuntu下SPICE的安装与配置
- IOS No architectures to compile for (ARCHS=i386, VALID_ARCHS=armv6 armv7)错误
- android 读写文本
- VC6.0下配置EON SDK
- C++语法表达式规则的建立基础
- puts()函数和printf函数的区别
- 技能是重要的
- Algorithms Part 1-Question 5- Dijkstra's shortest-path-最短路径算法
- Module for Steepest Descent or Gradient Method
- OpenCV-图像几何变换:旋转,缩放,斜切
- 设计模式心得体会(陆续更新)