In Java: create a unique random file name in a directory

How to create a random unique file name in a directory (of my choice)?

Note. . I do not want this file to be in the system time path, but in the directory that I specified

+4
source share
2 answers

File.createTempFile() allows you to specify a directory like this:

 File uniqueFile = File.createTempFile("post", ".html", new File("/var/www/doc")); 
+12
source

You need an overload of File.createTempFile(String, String, File) .

What would you see right away if you bother to look at the documentation.

-7
source

All Articles