Java tutorial
//package com.java2s; import android.net.Uri; import java.io.*; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static String generateFilePathForVideoSaveWithDraftUri(Uri draftUri) { String draftPath = draftUri.getPath(); String draftMediaDirPath = draftPath.substring(0, draftPath.length() - 5); File draftMediaDir = new File(draftMediaDirPath); if (!draftMediaDir.exists()) { draftMediaDir.mkdirs(); } return new File(draftMediaDir, generateRandomFilename("mp4")).getAbsolutePath(); } public static String generateRandomFilename(String ext) { SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd_HHmmss_SSS"); return df.format(new Date()) + "." + ext; } }