写的方法:
private void write(String content){
try {
FileOutputStream fos = openFileOutput("filename",MODE_APPEND);
fos.write(content.getBytes());
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
读的方法:
private String read(){
try {
FileInputStream fis = openFileInput("filename");
byte[] buffer = new byte[fis.available()];
fis.read(buffer);
return new String(buffer);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
android文件存取
最新推荐文章于 2020-04-24 11:43:14 发布