获得assets资源文件夹下的文本文件方法
2015-06-02 15:32
501 查看
//获得资源文件夹下的文本文件
public String getText(String name){
try {
//Return an AssetManager instance for your application's package
InputStream is = getAssets().open(name);
int size = is.available();
// Read the entire asset into a local byte buffer.
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
text = new String(buffer, "GB2312");
} catch (IOException e) {
// Should never happen!
throw new RuntimeException(e);
}
return text;
}
public String getText(String name){
try {
//Return an AssetManager instance for your application's package
InputStream is = getAssets().open(name);
int size = is.available();
// Read the entire asset into a local byte buffer.
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
text = new String(buffer, "GB2312");
} catch (IOException e) {
// Should never happen!
throw new RuntimeException(e);
}
return text;
}
相关文章推荐
- android 中可展开控件ExpandableListView的使用
- kafka部署及实例命令 彻底删除topic
- Spring管理Struts Action
- 多个tomcat 共享一个应用程序目录
- jResourceBundle解析配置文件详解
- 使用jasperreposts生成报表方法一
- C#里面中将字符串转为变量名
- POJ1328 -- 贪心算法和快速排序
- AndroidManifest.xml详解
- request.getContextPath(),request.getServletPath() 区别
- java servlet 几种页面跳转的方法
- MySQL utf8mb4 字符集
- 把excel数据生成sql insert语句
- 能够观看全球实时网路攻击的地图
- Xcode svn import项目 上传.a文件(静态库)
- 使用jasperreposts生成报表方法二,三
- iReport使用解析
- 潜藏在UPX壳中的隐患
- sequelize的使用
- 图片如何实现滑动效果