Multi-File upload and download, often need to consider the traditional file multiple times, how to accurately distinguish the name of the file, the following two methods can be achieved
1. The first method of implementation
The path path intercepts the filename from the service side.
String name = path.substring (39);
SimpleDateFormat format = new SimpleDateFormat ("Yyyymmddhhmmss");
String strFileName =format.format (New Date ()) + new Random (). Nextint ();
File File = new file (sdfile + "/video", strfilename+ "-" +name); Create a file object on the Android SDcard
2. The second way of implementation
* Generate Random file name
*/
Public String Generaterandomfilename () {
String randomfilename = "";
Random rand = new Random ();//Generate random number
int random = Rand.nextint ();
Calendar calcurrent = Calendar.getinstance ();
int intday = Calcurrent.get (calendar.date);
int intmonth = Calcurrent.get (calendar.month) + 1;
int intyear = Calcurrent.get (calendar.year);
String now = string.valueof (intyear) + "_" + string.valueof (intmonth) + "_" +
String.valueof (Intday) + "_";
Log.debug ("generated today's filename prefix is:" +now);
Randomfilename = Now + string.valueof (Random > 0? Random: (-1) * random) + ".";
return randomfilename;
}