• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating random file names  RSS feed

 
Sandeep Advani
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to create filenames dynamically ?

Application A accepts byte codes from multiple clients which it needs to write on to the disk saved as randomly generated file names. Application A needs to execute them after storing them in the local file system; hence handling and distinguishing multiple requests is necessary by saving them as separate file names. Any idea ?

Sandeep
 
shawn McFly
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about an array of whatever digits you want ..
and then a random number generator for the indices of the digits you want in your filename.

Sound like fun?
Simple, yet effective

STM
 
tommy k. lee
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The java.io.File class has an API to automatically create random file names:

static File createTempFile(String prefix, String suffix)

Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name
 
Sandeep Advani
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a bunch.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!