Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Picking a (random) file from a directory

 
Allen Bandela
Ranch Hand
Posts: 128
Eclipse IDE MS IE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Is there a way I can pick a file from a directory at random, or atleast the first file? I remember I could do it in VB.
I am trying to get the prefix of a "filename" from a bunch of identical filenames.
Also, I am doing this from an applet. So, I use URL(getDocumentBase() ,filename) to create a URL. I can't create a URL, if I don't know the filename.
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.io.File has several methods to list the files in a directory.
Of course there are security restrictions on applets you need to be aware of.
 
Allen Bandela
Ranch Hand
Posts: 128
Eclipse IDE MS IE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!