android 读取本地文件的一种方式
2016-11-15 16:14
218 查看
try {
String fileUri = "layout.xml";
InputStream is =MainApplication.getInstance().getAssets().open(fileUri);
int size = is.available();// Read the entire asset into a local byte
byte[] buffer = new byte[size];
is.read(buffer);
is.close();// Convert the buffer into a string.
content = new String(buffer, "gb2312");
} catch (Exception e) {
// TODO: handle exception
}
String fileUri = "layout.xml";
InputStream is =MainApplication.getInstance().getAssets().open(fileUri);
int size = is.available();// Read the entire asset into a local byte
byte[] buffer = new byte[size];
is.read(buffer);
is.close();// Convert the buffer into a string.
content = new String(buffer, "gb2312");
} catch (Exception e) {
// TODO: handle exception
}
相关文章推荐
- Android 如何以流的方式读取图片文件
- Unity3D IOS Android支持中文与本地文件的读取写入
- Unity3D研究院之IOS Android支持中文与本地文件的读取写入
- FileOutputStream字节输出流和FileInputStream输入流(切记:out是输出到本地中,in是输入到程序中)这里介绍大文件和小文件的读取方式
- 读取android目录下本地文件
- JJY本地服务器以服务方式运行不能读取消息文件
- 一种读取文件的方式
- android以流的方式读取文件
- android 读取本地的json文件
- Unity3D 游戏引擎之IOS Android支持中文与本地文件的读取写入
- Android以最省内存的方式读取本地资源的方法
- 一种处理从文件读取整数的方式
- android读取文件时乱码的问题,以及eclipse中java编码查看方式
- android-读取本地txt文件 - 随心
- Android文件的保存(本地和SD卡)与读取
- Android以最省内存的方式读取本地资源的(转)
- Android 文件存放路径和读取方式
- android 读取文件生成Bitmap的几种方式
- 读取本地文件更改文件名 Android
- Java方式读取本地服务器上的txt文件