Java tutorial
//package com.java2s; import android.os.Environment; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String LOG_FOLDER = Environment.getExternalStorageDirectory() + File.separator + "OBDCrashes" + File.separator; public static void createNewResultFileForConnexion() { Date currentDate = new Date(); SimpleDateFormat localDateFormat = new SimpleDateFormat("yyyyMMdd"); String logPath = LOG_FOLDER + "result_" + localDateFormat.format(currentDate) + "_" + System.currentTimeMillis() + ".txt"; try { File logFile = new File(logPath); FileWriter writer = new FileWriter(logFile, Boolean.TRUE); writer.write("Command\tCommand(hex)\tResult\tResult(Hex)\tLatency\n"); writer.close(); } catch (IOException e) { e.printStackTrace(); } } }