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

Android开发读取assert下的txt文件

2015-09-28 15:43 429 查看
在Android工程的assert根目录下存在txt文件test.txt文件,读取内容的办法如下:

String content = "加载错误";

try

{

InputStream is = getAssets().open("test.txt");

int size = is.available();

byte[] buffer = new byte[size];

is.read(buffer);

is.close();

content = new String(buffer, "GB2312");

} catch (Exception e)

{

}

TextView tv = (TextView) findViewById(R.id.tv);

tv.setText(content);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: