4 Replies - 540 Views - Last Post: 05 January 2013 - 03:12 PM Rate Topic: -----

#1 my3best  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 14-December 12

how to get all mp3 files in my windows system using jtree in java

Posted 04 January 2013 - 09:00 PM

how to get all mp3 files in my windows system including (c:,d:,e:,ect) using jtree in java.
im just getting all directories & files in specific directories but i know wish to get all mp3 files in my all system drives
Is This A Good Question/Topic? 0
  • +

Replies To: how to get all mp3 files in my windows system using jtree in java

#2 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1155
  • View blog
  • Posts: 2,533
  • Joined: 05-May 05

Re: how to get all mp3 files in my windows system using jtree in java

Posted 04 January 2013 - 09:42 PM

How about recursively searching from the root of each drive?
Was This Post Helpful? 2
  • +
  • -

#3 grimpirate  Icon User is offline

  • Pirate King
  • member icon

Reputation: 149
  • View blog
  • Posts: 714
  • Joined: 03-August 06

Re: how to get all mp3 files in my windows system using jtree in java

Posted 05 January 2013 - 01:34 PM

As blackcompe suggested, retrieve all your root directories:

http://docs.oracle.c...al/io/dirs.html

Then recurse through them filtering filenames. Though I imagine this will probably take a large sum of time.
Was This Post Helpful? 2
  • +
  • -

#4 cfoley  Icon User is online

  • Cabbage
  • member icon

Reputation: 1989
  • View blog
  • Posts: 4,133
  • Joined: 11-December 07

Re: how to get all mp3 files in my windows system using jtree in java

Posted 05 January 2013 - 02:23 PM

It would take a long time to scan the whole file system upfront. You could make the application appear a lot faster if you only scan a directory when you expand a node in the tree. You could make it seem lightning fast if you preload the contents of all the visible folders in the background.
Was This Post Helpful? 2
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: how to get all mp3 files in my windows system using jtree in java

Posted 05 January 2013 - 03:12 PM

You have to aspect of a problem and you seems to have incorrectly merged them :)

A JTree is just a fancy GUI component to display data
Your Data is all the .MP3 files below few root directories

You can have 2 different approachs to this problem:
- scan all the directories for the .MP3 files, save that data in a data structure and then fill your JTree based oon that data structure
- display in the JTree the root directories and then start the search when one of them is clicked dinamically expanding them when required
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1