• Post Reply Bookmark Topic Watch Topic
  • New Topic

File.createTempFile() question  RSS feed

 
Stephanie Smith
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I use File.createTempFile(), does it
make sure that the file does not already
exist before it creates the file?
Or do I need to provide some uniqueness
with the suffix/prefix info I provide?
 
Bhupinder Dhillon
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe this excerpt taken from File.createTempFile javadoc will answer your question.

If this method returns successfully then it is guaranteed that:
1. The file denoted by the returned abstract pathname did not exist before this method was invoked, and
2. Neither this method nor any of its variants will return the same abstract pathname again in the current invocation of the virtual machine.

[ February 27, 2003: Message edited by: Bhupinder Dhillon ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!