android从资源文件中读取文件流显示
扫描二维码
随时随地手机看文章
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这个就可以了