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 06-12-2008, 02:44 PM
Member
 
Join Date: Jun 2008
Posts: 4
KevMeistr is on a distinguished road
Filename Filter problem
Hi there..

I recently discovered the File class and how useful it is when searching for files in a certain directory..

Now, I want to pass 2 string parameters;

1. Directory name
2. A filter

The passing of the 2 strings will be in a constructor..

Is there any way that I'm able to search in a directory for a filter corresponding to the string "E.*\.htm"..the reason for doing this is so that I can put .htm files starting with "E" into an array by themselves
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-12-2008, 05:27 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 527
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Quote:
2. A filter
You may design a class that extends FileFilter....

And override the two methods getDescription() and accept()

All filtering operations should be done on overriden accept(File) method....

You may browse the FileFilter class in src file(zip) that can be found inside jdk folder....(just in case you are curious about its implementation)

Hope that helps,
sukatoa
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by sukatoa : 06-12-2008 at 05:31 PM.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-14-2008, 04:43 AM
danielstoner's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Canada
Posts: 191
danielstoner is on a distinguished road
Try this

Code:
File dir = new File("E:\"); File[] files = dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("*.htm") ? true : false; } });
__________________
Daniel @ [
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
]
Language is froth on the surface of thought
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
how to display the picture when the filename is not in order norazanita New To Java 5 06-06-2008 11:31 AM
web content filter or internet filter sundarjothi Advanced Java 3 05-15-2008 01:36 PM
Reading a directory and getting the filename mrjunsy Advanced Java 1 05-10-2008 04:36 AM
servlet Filter problem saint_jorjo New To Java 1 03-13-2008 02:05 PM
Need a filter revathi17 New To Java 1 08-08-2007 09:37 PM


All times are GMT +3. The time now is 12:37 PM.


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