generate Unique File Name - Java java.io

Java examples for java.io:File Name

Description

generate Unique File Name

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        String prefix = "java2s.com";
        String suffix = "com";
        System.out.println(generateUniqueFileName(prefix, suffix));
    }//w  ww. j a v  a2 s.  c  o m

    public static String generateUniqueFileName(String prefix, String suffix) {
        return (prefix != null ? prefix : "") + System.nanoTime()
                + (suffix != null ? suffix : "");
    }
}

Related Tutorials