android_读取assets中的图片和文本文档
2017-03-27 14:41
459 查看
图片
try {
InputStream in = this.getAssets().open("p002.bmp");
Bitmap bm = BitmapFactory.decodeStream(in);
in.close();
in = null;
iv.setImageBitmap(bm);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
文本文档
try {
InputStream fis = this.getAssets().open("jz.txt");
int count = fis.available();
byte[] bytes = new byte[count];
int len=0;
while((len=fis.read(bytes))!=-1){
System.out.println(len);
aa=aa+new String(bytes,0,len);
}
b.setText(aa);
fis.close();
fis = null;
} catch (IOException e) {
e.printStackTrace();
}
不要忘记加权限
try {
InputStream in = this.getAssets().open("p002.bmp");
Bitmap bm = BitmapFactory.decodeStream(in);
in.close();
in = null;
iv.setImageBitmap(bm);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
文本文档
try {
InputStream fis = this.getAssets().open("jz.txt");
int count = fis.available();
byte[] bytes = new byte[count];
int len=0;
while((len=fis.read(bytes))!=-1){
System.out.println(len);
aa=aa+new String(bytes,0,len);
}
b.setText(aa);
fis.close();
fis = null;
} catch (IOException e) {
e.printStackTrace();
}
不要忘记加权限
![](http://www.sinaimg.cn/uc/myshow/blog/misc/gif/E___6715EN00SIGG.gif)
相关文章推荐
- android-读取Assets图片资源保存到SD - 随心
- Android读取assets目录下的所有图片并显示的方法
- android-读取Assets图片资源保存到SD - 随心
- Android 读取Assets中图片
- android读取Assets图片资源保存到SD卡然后显示到ImageView里 实例
- Android:漫画APP开发笔记之从Assets本地读取图片
- Android 读取Assets中图片
- 从Android读取Unity assets下的图片并保存为Bitmap格式
- Android从Assets中读取图片
- Android 读取Assets中图片
- Android 读取Assets中图片
- Android 读取Assets中图片
- Android从assets中读取文本和图片资源
- Android 读取Assets中图片
- Android 读取Assets中图片
- Android 读取Assets中图片
- android 存储图片到data目录和读取data目录下的图片
- android从assets和res文件夹中读取资源
- android 从assets和res中读取文件(转)