PDA

View Full Version : java search


keatonvictor
16th October 2007, 04:22 PM
Hi guys

I am building a MP3 Player using java, now I want to be able to run through a directory and add all the songs from that directory to an array. by that I men the full location such as

/songs/song1.mp3
/songs/song2.mp3
/songs/song3.mp3
/songs/song4.mp3
/songs/song5.mp3


However I want to stop it from adding any files that are not MP3

Is there a way I can search for particular files using java and then copy their corresponding URL ? i want this to work in windows as well.

tashirosgt
16th October 2007, 09:43 PM
Are you wanting to use a gui file selector in this program. If you don't need one of those, just put the list of files in the directory in a list, loop through it and pull out those ending in mp3. http://www.exampledepot.com/egs/java.io/GetFiles.html

ppesci
17th October 2007, 12:11 AM
I remember a code on demo directory (SwingSet or SwingSet2) that does what you want. See the source code. I know you can assign a filter but my memory is not as good as I want :).

You can in other way, put in a Vector, all entries in a directory and filter it.

HTH

Pollenca Travel Photos on Instagram - Madiun - Banat Instagram Photos