How do I create a random unique filename in a directory (of my choice)?
Note: I don’t want this file in the system temp path but rather in the directory I specify
How do I create a random unique filename in a directory (of my choice)?
Note: I don’t want this file in the system temp path but rather in the directory I specify
File.createTempFile()
allows you to specify a directory so:
File uniqueFile = File.createTempFile("post", ".html", new File("/var/www/doc"));
You want the File.createTempFile(String, String, File)
overload.
Which you would have seen immediately had you bothered to look at the documentation.