Reputation: 16252
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
Upvotes: 4
Views: 12067
Reputation: 625057
File.createTempFile()
allows you to specify a directory so:
File uniqueFile = File.createTempFile("post", ".html", new File("/var/www/doc"));
Upvotes: 14
Reputation: 59983
You want the File.createTempFile(String, String, File)
overload.
Which you would have seen immediately had you bothered to look at the documentation.
Upvotes: -8