赞
踩
第一步:
第二步:
第三步:
/** * 从assets下的txt文件中读取数据 */ public String initAssets(String fileName) { String str = null; try { InputStream inputStream = getAssets().open(fileName); str = getString(inputStream); } catch (IOException e1) { e1.printStackTrace(); } return str; } public static String getString(InputStream inputStream) { InputStreamReader inputStreamReader = null; try { inputStreamReader = new InputStreamReader(inputStream, "UTF-8"); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } BufferedReader reader = new BufferedReader(inputStreamReader); StringBuffer sb = new StringBuffer(""); String line; try { while ((line = reader.readLine()) != null) { sb.append(line); sb.append("\n"); } } catch (IOException e) { e.printStackTrace(); } return sb.toString(); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。