File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To fetch files from a dir

 
Chhaya Dhanani
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, this comes as an SOS
I am developing an application using Swings
I have to pick up all files with extension .dat from say a dir called "c:\chhaya".
how do i go about doing this.
I should show thw total number of files with .dat extension and then populate a JList which allows multiple selection with those file names.
populating the JList is no problem.
how do i get or search for files with a specific extension in a specific dir.
Thannx in advance
Please reply as soon as possible
Chhaya
 
John Zukowski
Author
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the listFiles() methods of File. You can pass in a filter to say what type of files you want.
------------------
John Zukowski Author of "Definitive Guide to Swing for Java 2" and "Java Collections"
 
Chhaya Dhanani
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks John,
I went thru' the API
but am still confused as to how i should go about implemneting FilenameFilter interface
a code snippet from you would definitely help
thanx
PS. please reply today itself, if possible
 
Angela Lamb
Ranch Hand
Posts: 156
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is only one method in FilenameFilter that needs to be implemented. Here is a filter that accepts only JSP files:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic