android java 文件操作
2018-01-22 15:19 二进制乐谱 阅读(283) 评论(0) 收藏 举报
按行读取文件中内容:
public static List<String> read() { List<String> _list = new ArrayList<String>(); String sdpath=getInnerSDCardPath(); String filterpath = sdpath+"/filter"; File f = new File(filterpath); BufferedReader reader = null; String tempstr =null; try { reader = new BufferedReader(new FileReader(f)); tempstr =reader.readLine(); while (null!=tempstr) { _list.add(tempstr); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return _list; }
读取sdk上的内容:
1.加入权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
public static String getInnerSDCardPath() {
return Environment.getExternalStorageDirectory().getPath();
}
浙公网安备 33010602011771号