import java.text.SimpleDateFormat; static void androidLifecycle(O line) ctex { if (line instanceof Throwable) line = getStackTrace((Throwable) line); line = "[" + new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()) + "] " + line; String path = "/storage/sdcard0/JavaX_System/lifecycle.txt"; new File(path).getParentFile().mkdirs(); RandomAccessFile raf = new RandomAccessFile(path, "rw"); raf.seek(raf.length()); raf.write((line + "\n").getBytes("UTF-8")); raf.close(); }