Java File Name Create generateFileName(String fileName)

Here you can find the source of generateFileName(String fileName)

Description

generate File Name

License

Open Source License

Declaration

public static String generateFileName(String fileName) 

Method Source Code


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

Related

  1. filename(String prefix, String sep, String index)
  2. FileName(String[] args)
  3. generateFileId(String userlogin)
  4. generateFileName()
  5. generateFileName()
  6. generateFileNameWithoutExtension(final String testClassName, final String testId, final boolean includeDate)
  7. getRandomFileName(@Nullable final String prefix)
  8. toFileName(final Object obj)
  9. toFileName(String address)