I want to be able to create a temporary text File in Java to display on screen, but using File.createTempFile() does not give me enough control over its name.
Any thoughts here?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Why do you need such control over the name of a temporary file?
That question aside, no you can’t have full control over the name of the file generated by
createTempFile. If you really need full control, you need to create a regularFileinstead.You may want to make use of the following:
java.io.tmpdirSystem property for temporary file directorycreateNewFile()to check for naming conflictsdeleteOnExit()