• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating UniqueName Files??  RSS feed

 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to generate a report in a particulat format. I have generated that file successfully but its only one file taht i have created.What i want to do is whenever i generate taht report it should get created with a unique name??

So how to do that??

Thanks,
Jignesh
 
Martin Simons
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try putting the date and time into the name (including second). Then two
reports would have to be created in the same second to have the same name.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the File API for createTempFile. I don't think there's any reason that the file has to be "temporary." I'd say you can put it in any directory and keep it as long as you like.
 
Michael Powe
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the File API for createTempFile. I don't think there's any reason that the file has to be "temporary." I'd say you can put it in any directory and keep it as long as you like.


In fact, it's not temporary unless you explicitly call deleteOnExit(). The only drawback I see to this method is you can't control the filenames. You control the first 3 chars and the extension, but the rest of the filename will be gibberish.

I might suggest writing a temp file and then renaming it using some convention that makes sense in the context in which the files will be used.

thanks.

mp
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!