Java Temp File Create getUniqueFileName(String fileNamePrefix, String fileExtension)

Here you can find the source of getUniqueFileName(String fileNamePrefix, String fileExtension)

Description

get Unique File Name

License

Open Source License

Declaration

public static String getUniqueFileName(String fileNamePrefix,
            String fileExtension) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Educational Online Test Delivery System Copyright (c) 2014 American
 * Institutes for Research//from www.  jav  a  2s.co m
 * 
 * Distributed under the AIR Open Source License, Version 1.0 See accompanying
 * file AIR-License-1_0.txt or at http://www.smarterapp.org/documents/
 * American_Institutes_for_Research_Open_Source_Software_License.pdf
 ******************************************************************************/

import java.text.DateFormat;

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static String getUniqueFileName(String fileNamePrefix,
            String fileExtension) {
        Date d = Calendar.getInstance().getTime();
        long now = System.currentTimeMillis();
        return "QTIScoringEngine_"
                + fileNamePrefix
                + "_"
                + DateFormat.getDateInstance(DateFormat.SHORT).format(d)
                        .replace("/", "-")
                + "_"
                + DateFormat.getTimeInstance(DateFormat.LONG).format(d)
                        .replace(" ", "").replace(":", "_") + fileExtension;
    }
}

Related

  1. getTempFileWithFullPath()
  2. getUniqueAFileName(String ext)
  3. getUniqueFile(File dir, String prefix, String suffix)
  4. getUniqueFileName()
  5. getUniqueFilename(String filename, String extension)
  6. getUniqueFileName(String originalFileName)
  7. getUniqueTempFile(final boolean autoDelete, final File parentFolder, final String suffix)
  8. newTmpFile(String content)
  9. newTmpFile(String content, String encoding)