Android对本地txt的文件读取
2016-08-19 18:06
337 查看
public class Read_I_O { List<String> textList; public static List<String> readTxtFile(){ List<String> re=new ArrayList<String>(); String name = "black_keywords.txt"; try { String encoding="UTF-8"; //File file=new File(filePath); InputStream in = XileApplication.getInstance().getApplicationContext().getAssets().open(name);//该文件位置为assets下 //判断文件是否存在 InputStreamReader read = new InputStreamReader( in,encoding);//考虑到编码格式 BufferedReader bufferedReader = new BufferedReader(read); String lineTxt = null; while((lineTxt = bufferedReader.readLine()) != null){ re.add(lineTxt); } read.close(); } catch (Exception e) { System.out.println("读取文件内容出错"); e.printStackTrace(); } return re; } public List<String> getTextList() { if (textList==null) { textList=readTxtFile(); } return textList; } }
相关文章推荐
- Android 读取本地txt文件中的内容
- android-读取本地txt文件 - 随心
- Android读取本地TXT文件
- Android 读取raw下的txt文件
- android读取data/data/包名/file路径下的txt文件
- android 读取TXT文件
- android从raw里面读取txt文件
- android 读取SD卡下TXT文件
- android 3d游戏研究(二)(边学边写,多谢高手指正,鞠躬) :txt文件读取
- 用URLLoader读取本地txt,xml等格式文件
- Android中读取一个txt文本文件,然后显示到界面上的操作
- 【string编码格式】Android读取txt文件乱码问题
- Android在终端本地保存txt文本文件及zip文件
- 读取android项目assets目录下的txt文件.
- 【java】【乱码】Java 读取本地 UTF8 txt文件乱码处理
- iphone app中读取本地txt,csv文件
- Java 读取本地 UTF8 txt文件乱码处理
- android中需要读取assets目录下a.txt文件并进行解析
- android 读取raw下TXT文件
- 基于android中读取assets目录下a.txt文件并进行解析的深入分析