android读写文件函数代码
16lz
2021-12-23
private void readFromFile() { try { FileInputStream file = openFileInput("test.txt"); byte[] buffer = new byte[file.available()]; file.read(buffer); file.close(); String name=new String(buffer); TextView text = (TextView) findViewById(R.id.test); text.setText(name); } catch (IOException e) { e.printStackTrace(); } } private void writeToFile() { try { String str = "测试中文"; FileOutputStream file = openFileOutput("test.txt", MODE_APPEND); file.write(str.getBytes()); file.close(); } catch (IOException e) { e.printStackTrace(); } }
更多相关文章
- Android自动测试之MonkeyRunner之monkeyrunner
- Android(安卓)CTS 兼容性测试的Fail的一些修改
- Android(安卓)动态布局 (代码布局)
- Android(安卓)CTS Test
- Android(安卓)CTS Verifier Sensor Test Cases (1)
- android 性能优化
- android折叠展开自定义列表项测试
- Android限制EditText只能输入中文、英文、数字
- android中ActionBar +Fragment