android读取raw文件示例
内容摘要
复制代码 代码如下:// 读取raw文件private void rawRead(){String ret = "";try {InputStream is = getResources().openRawResource(R.raw.my_raw);int len = is.available
文章正文
复制代码 代码如下:
// 读取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);
}
代码注释