新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > android從資源文件中讀取文件流顯示

android從資源文件中讀取文件流顯示

作者: 時(shí)間:2016-09-12 來(lái)源:網(wǎng)絡(luò) 收藏

1. Java]代碼

本文引用地址:http://www.2s4d.com/article/201609/305203.htm

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這個(gè)就可以了



關(guān)鍵詞:

評(píng)論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉