Why do you need such control over the name of a temporary file?
There is no question in this, you cannot completely control the name of the file generated by createTempFile . If you really need full control, you need to create a regular File .
You might want to use the following:
java.io.tmpdir System property for the temporary file directorycreateNewFile() to check for name conflicts.deleteOnExit()
source share