您的位置 首页 应用

android从资源文件中读取文件流显现

1. Java]代码private void doRaw(){InputStream is = this.getResources().openRawResource(R.raw.ziliao);tr

1. Java]代码

private void doRaw(){

InputStream is = this.getResources().openRawResource(R.raw.ziliao);

try{

doRead(is);

}catch(IOException e){

e.printStackTrace();

}

}

private void doRead(InputStream is) throws IOException{

DataInputStream dis = new DataInputStream(is);

byte[]buffer = new byte[is.available()];

dis.readFully(buffer);

textView.setText(new String(buffer));

dis.close();

is.close();

}

//便是用this.getResources().openRawResource这个就可以了

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/yingyong/299456.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部