阅读更多

例如raw文件夹下面的文件是w_city_code.txt,那么读取参考代码如下:

 

BufferedReader reader=new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.w_city_code)));boolean found=false;try {String line;String name;boolean isPreEmpty=true;while((line=reader.readLine())!=null){if(line.length()>10){if(isPreEmpty){name=line.substring(10);if(name.equals(cityName)){// find the city for shenghuifound=true;// search the city names and fill the listcities=searchCitys(line.substring(0, 9),line.substring(10),reader);fillCities(cities);break;}}isPreEmpty=false;}else{isPreEmpty=true;}}} catch (IOException e) {e.printStackTrace();}finally{try {reader.close();} catch (IOException e) {e.printStackTrace();}if(!found){setListAdapter(null);}}

更多相关文章

  1. Android(安卓)studio编译警告:请使用 -Xlint:deprecation 重新编
  2. Android培训班(36)
  3. 【android 文件的基本操作】
  4. TextView 在xml文件中的解释 android
  5. Android的Eclipse升级笔记
  6. android apk编译
  7. 音视频转码合成
  8. android 编写命令行测试程序
  9. android wifi连接

随机推荐

  1. Android(安卓)PKMS深入分析安装应用
  2. Cocos2d-x android can't resolved cosco
  3. Android传感器
  4. VLC for Android(安卓)on Linux
  5. 让背景小图不是拉伸而是多个重复
  6. Android捕获Home按键
  7. Android应用程序绑定服务(bindService)的过
  8. android:configChanges="keyboard|keyboa
  9. Android(安卓)创建,验证和删除桌面快捷方
  10. Android图形报表之AchartEngine(附开发包