您的位置:首页 > 移动开发 > Android开发

Android 读写文件方法汇总

2013-07-29 09:57 1286 查看
//写文件在./data/data/com.tt/files/下面public voidwriteFileData(String fileName,String message){try{FileOutputStream fout =openFileOutput(fileName, MODE_PRIVATE);byte [] bytes = message.getBytes();fout.write(bytes);fout.close();}catch(Exception e){e.printStackTrace();}}//-------------------------------------------------------//读文件在./data/data/com.tt/files/下面public String readFileData(String fileName){String res="";try{FileInputStream fin = openFileInput(fileName);int length = fin.available();byte [] buffer = new byte[length];fin.read(buffer);res = EncodingUtils.getString(buffer, "UTF-8");fin.close();}catch(Exception e){e.printStackTrace();}return res;}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Android 读写文件