• Post Reply Bookmark Topic Watch Topic
  • New Topic

Building a treeset of files, with not much success yet  RSS feed

 
Yotam Ohayon
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there
i am trying to implement a TreeSet containing all files/sub folders in the run-time folder.
i want the objects (FILE objects) to be sorted by name. here's what i have:

notice: comp is of type ABS, that's a class implementing Comparator and it sorts files by their name.
i have 5 different files and two sub folders (src and bin) in the run-time folder but it only gets one file (tester) and one folder(src). the others are ignored.


any suggestions?
this is my first time working with a TreeSet, the java tutorial on it is not very informative in my opinion
thanks!
 
Stephan van Hulst
Saloon Keeper
Posts: 7817
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without seeing ABS, there's not much we can say about the problem.

Note that File implements Comparable. Read what Comparable does, and what TreeSet does if you don't pass any arguments to its constructor.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!