Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-25-2007, 09:34 PM
Member
 
Join Date: May 2007
Posts: 6
karma is on a distinguished road
How can I get list of files in a directory
I want get the list of filenames, such as "d:\javafile\*.java"
The return values could be String[] or FIle[].

How can i do this?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-25-2007, 10:42 PM
Member
 
Join Date: May 2007
Posts: 7
FaRuK is on a distinguished road
Hi Karma,

I think you'd do it something like:

Code:
File dir = new File ("d:/javafile/"); String [] javafiles = dir.list(filter); for (int i = 0; i < strs.length; i++) { System.err.println (strs[i]); } }
And for filtering only *.java files, you can use the following filter:

Code:
FilenameFilter filter = new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".java"); } });
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-15-2007, 01:20 AM
Member
 
Join Date: Dec 2007
Posts: 13
MattStone is on a distinguished road
above should work....
depending on what you want.....

You may want to follow along with me, LoL
getting kinda crazy. LoL. but similar post.
can java.io.File create a list of all files and folders.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text and image files within jar files erhart Advanced Java 8 01-19-2008 06:43 AM
Deleting an directory/subdirectory/files Java Tip Java Tips 0 01-13-2008 09:18 AM
can java.io.File create a list of all files and folders. MattStone New To Java 20 12-17-2007 05:20 PM
how to convert mpeg files to .wav files christina New To Java 1 08-06-2007 06:14 AM
how to find files in given directory cecily New To Java 1 08-05-2007 06:26 AM


All times are GMT +3. The time now is 03:31 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org