Android 保存文件到本地(一)
2015-12-17 11:09
369 查看
public boolean method1(String conent) { String path = "./mnt/sdcard/ucabCrash/"; String fileName = "myloction.txt"; File dirFile = new File(path); File file = new File(path + fileName); if (!dirFile.exists()) { dirFile.mkdirs(); try { file.createNewFile(); } catch (Exception e) { Log.e("calm", "------创建异常---"); return false; } } SimpleDateFormat sdf = new SimpleDateFormat("yyyy MM dd HH:mm:ss", Locale.getDefault()); long timestamp = System.currentTimeMillis(); String time = sdf.format(new Date(timestamp)); conent = time + conent + '\n'; BufferedWriter out = null; try { out = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(path + fileName, true))); out.write(conent); } catch (Exception e) { e.printStackTrace(); } finally { try { out.close(); } catch (IOException e) { e.printStackTrace(); } } return true; }
相关文章推荐
- Android 混合开发 的一些心得。
- [Android]android.graphics.Camera实现图像的旋转、缩放,配合Matrix实现图像的倾斜
- 【android】getCacheDir()、getFilesDir()、getExternalFilesDir()、getExternalCacheDir()的作用
- 配置android开发环境
- Android-Layout_weight属性解析(慕课网笔记)
- Android 4.0以后屏蔽Home键和返回键
- Android 单例模式的问题
- Android之图片窗口和大小调节
- android 获取视频缩略图终极解决方案(ffmpeg)
- Android -- View移动的六种方法
- android drawable
- 【Android基础学习】TextView参数设置
- Android 短信验证码自动填写
- android——fragment详解
- android中获取布局文件的三种方式
- Android开发反编译与混淆
- Android PopupWindow
- 将Eclipse代码导入到AndroidStudio的两种方式
- android------使用TextView链接打开一个Activity
- android开发之colores.xml----常用颜色