android 读取本地文件的一种方式

来源:互联网 发布:张艺兴发布会知乎 编辑:程序博客网 时间:2024/05/16 11:09

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
}

0 0
原创粉丝点击