Android 寫入log file

摘要:Android 寫入log file

String filePath = android.os.Environment.getExternalStorageDirectory() + java.io.File.separator;
File file = new File(filePath + CONFIG_LOG_FILE_NAME);

BufferedWriter out = null
out = new BufferedWriter(new FileWriter(file, true))
out.append(String物件);

DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date now = new Date();
dateFormat.format(now);

finally {
    if (out != null) {
        out.flush();
        out.close();
    }
}