android reads the raw file example

  • 2020-05-30 21:01:48
  • OfStack


//  read raw file 
private void rawRead(){
String ret = "";
try {
InputStream is = getResources().openRawResource(R.raw.my_raw);
int len = is.available();
byte []buffer = new byte[len];
is.read(buffer);
ret = EncodingUtils.getString(buffer, "utf-8");
is.close();
} catch (Exception e) {
e.printStackTrace();
}
tvTXT.setText(ret);
}


Related articles: