1 public String getFromRaw(){
2 String result = "";
3 try {
4 InputStream in = getResources().openRawResource(R.raw.story);
5 //获取文件的字节数
6 int lenght = in.available();
7 //创建byte数组
8 byte[] buffer = new byte[lenght];
9 //将文件中的数据读到byte数组中
10 in.read(buffer);
11 result = EncodingUtils.getString(buffer, ENCODING);
12 } catch (Exception e) {
13 e.printStackTrace();
14 }
15 return result;
16 }