android读取raw文件示例
程序员文章站
2023-12-29 08:02:58
复制代码 代码如下:// 读取raw文件private void rawread(){string ret = "";try {inputstream is = getre...
复制代码 代码如下:
// 读取raw文件
private void rawread(){
string ret = "";
try {
inputstream is = getresources().openrawresource(r.raw.my_raw);
int len = is.available();
byte []buffer = new byte[len];
is.read(buffer);
ret = encodingutils.getstring(buffer, "utf-8");
is.close();
} catch (exception e) {
e.printstacktrace();
}
tvtxt.settext(ret);
}