您的位置:首页 > 移动开发 > Android开发

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
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: