`
gintama
  • 浏览: 49722 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

android文件存取

 
阅读更多
写的方法:

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;
	}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics