Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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;
    }
}