微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > android从资源文件中读取文件流显示

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

时间:09-12 来源:互联网 点击:

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这个就可以了

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top