Here you can find the source of generateFileName(String fileName)
public static String generateFileName(String fileName)
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Random; public class Main { public static String generateFileName(String fileName) { DateFormat format = new SimpleDateFormat("yyMMddHHmmss"); String formatDate = format.format(new Date()); int random = new Random().nextInt(10000); int position = fileName.lastIndexOf("."); String extension = fileName.substring(position); return formatDate + random + extension; }/*from w ww . j av a 2s. c o m*/ }