Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / November 2005

Tip: Looking for answers? Try searching our database.

File I/O question

Thread view: 
Huub - 20 Nov 2005 10:29 GMT
Hi,

I would like to look for a filename consisting of at least an 'a' and
'.txt' and then let the program just search the disk for it. When
looking at file I/O (e.g. at mindprod) I get the impression that I won't
be able to just scan through the filestructure on disk. Is this a
correct assumption?

Thanks,

Huub
Andrew Thompson - 20 Nov 2005 10:59 GMT
> I would like to look for a filename consisting of at least an 'a' and
> '.txt' and then let the program just search the disk for it. When
> looking at file I/O (e.g. at mindprod) I get the impression that I won't
> be able to just scan through the filestructure on disk. Is this a
> correct assumption?

No.  A simple search nehtod starting at a root
can iterate File.listFiles() and recursively
call the method on File.isDirectory()s.

Use File.listFiles(FileNameFilter) fo find your
target files.

This may cause problems on *nix systems with symbolic links
(although I thought code might File.getCanonicalPath() and
pop them in a map to ensure it does not go into infinite
loops, I never pursued it..).

(And please bookmark the JavaDocs[1].  MindProd is a great
resource, but there are many things it does not tell you,
given they are listed in the comprehensive Java tutorials
at Sun, and the JavaDocs.)

[1] Overview
<http://java.sun.com/j2se/1.5.0/docs/api/overview-summary.html>
File
<http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html>

Signature

Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew
Currently accepting short and long term contracts - on Earth.

Roedy Green - 20 Nov 2005 14:27 GMT
On Sun, 20 Nov 2005 10:59:36 GMT, Andrew Thompson
<seemysites@www.invalid> wrote, quoted or indirectly quoted someone
who said :

>(And please bookmark the JavaDocs[1].  MindProd is a great
>resource, but there are many things it does not tell you,
>given they are listed in the comprehensive Java tutorials
>at Sun, and the JavaDocs.)

If you notice an entry at mindprod.com that is missing a link to the
corresponding JavaDoc in the "learning more" section, please let me
know and I will add it.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Andrew Thompson - 20 Nov 2005 14:34 GMT
> On Sun, 20 Nov 2005 10:59:36 GMT, Andrew Thompson
> <seemysites@www.invalid> wrote, quoted or indirectly quoted someone
[quoted text clipped - 8 lines]
> corresponding JavaDoc in the "learning more" section, please let me
> know and I will add it.

Oh, good point.  Sorry Roedy, but lacking an URL from the OP,
I was not sure exactly what page they were referring to, and
did not go hunting.

So I suppose I should change that to "don't forget to
chase the links..".

Signature

Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew
Currently accepting short and long term contracts - on Earth.

Huub - 20 Nov 2005 15:50 GMT
> (And please bookmark the JavaDocs[1].  MindProd is a great
> resource, but there are many things it does not tell you,
> given they are listed in the comprehensive Java tutorials
> at Sun, and the JavaDocs.)

Have it bookmarked. Thank you.
Roedy Green - 20 Nov 2005 14:25 GMT
>I would like to look for a filename consisting of at least an 'a' and
>'.txt' and then let the program just search the disk for it. When
>looking at file I/O (e.g. at mindprod) I get the impression that I won't
>be able to just scan through the filestructure on disk. Is this a
>correct assumption?

use File.list and a FilenameFilter to scan one directory.
See http://mindprod.com/jgloss/file.html
http://mindprod.com/jgloss/filter.html

use File.isDirectory to identify directories in the list and process
tem recursively.

You might find ClamFilter, RegexFilter, allDirectoriesFilter useful.
see http://mindprod.com/products1.html#FILTER
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Huub - 20 Nov 2005 15:50 GMT
> use File.list and a FilenameFilter to scan one directory.
> See http://mindprod.com/jgloss/file.html
[quoted text clipped - 5 lines]
> You might find ClamFilter, RegexFilter, allDirectoriesFilter useful.
> see http://mindprod.com/products1.html#FILTER

Thank you.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.