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();
}
}