zl程序教程

您现在的位置是:首页 >  其他

当前栏目

读取Assets中的文件数据

文件数据 读取 assets
2023-09-14 08:59:00 时间
 1 try {
 2             // 返回的字节流
 3             InputStream is = getResources().getAssets().open("info.txt");
 4             // 当读取时,属于文本文件的时候,需要将它包装成字符流。
 5             InputStreamReader isr = new InputStreamReader(is, "UTF-8");
 6             // 进一步进行包装
 7             BufferedReader bfr = new BufferedReader(isr);
 8             String in = "";
 9             while ((in = bfr.readLine()) != null) {
10                 Log.i("AAA", in);                
11             }
12         } catch (IOException e) {
13             e.printStackTrace();
14         }