Article View: borland.public.jbuilder.java.api
Article #3185how to use FilenameFilter?
From: Bill Rooney
Date: Tue, 14 Apr 1998 00:00
Date: Tue, 14 Apr 1998 00:00
24 lines
1423 bytes
1423 bytes
All,
I have the following code that should display only the contents of
the current directory that match the filter. I am having trouble
setting the filter, because I believe it will only work in a FileDialog.
Has anyone used filters in a text-only based application, not a gui?
String filter;
FilenameFilter filenameFilter; //how do I instantiate
filenameFilter??
System.out.print("Enter FilenameFilter: ");
filenameFilter = BR.readLine(); //this does not work, it is not
supposed to be a String
filenameFilter.setFilenameFilter(filenameFilter); //this seems to
work only for FileDialog
String directory[] = file.list(filenamefilter); //this should work,
once I instantiate filenameFilter
for(int i=0; i<directory.length; i++)
System.out.print(directory[i] + " "); //prints all filenames on
the same line
Thanks in advance,
----Bill Rooney
Technical Details
Message-ID:
<35337F79.6B06C2BA@pitt.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,cb73ce1fa441f8b8,start X-Google-Attributes: gid1089d0,public From: Bill Rooney <worst+@pitt.edu> Subject: how to use FilenameFilter? Date: 1998/04/14 Message-ID: <35337F79.6B06C2BA@pitt.edu> X-Deja-AN: 343910600 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Reply-To: wor96@bigfoot.com Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.api