private static void saveCrashInfo2File(String sb) { String fileName = "CSM.txt"; FileWriter writer = null; try { File dir = new File("/sdcard/AAAAcsm/"); if (!dir.exists()) dir.mkdirs(); //打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件 writer = new FileWriter(new File(dir, fileName).getAbsolutePath(), true); writer.write(sb); } catch (Exception e) { e.printStackTrace(); } finally { if (writer != null) { try { writer.close(); } catch (Exception e) { e.printStackTrace(); } } } }
saveCrashInfo2File("Login:" + getEncryptCode() + "\n");