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 / General / September 2006

Tip: Looking for answers? Try searching our database.

parsing multiple files

Thread view: 
Peter Parker - 30 Aug 2006 02:03 GMT
How could one parse multiple files within a folder and its subfolders in
search for a string, for instance? I see examples of parsing a single file.
Thanks.
Arne Vajhøj - 30 Aug 2006 02:14 GMT
> How could one parse multiple files within a folder and its subfolders in
> search for a string, for instance? I see examples of parsing a single file.

Something like:

   private static void process(String name) {
      File f = new File(name);
      if (f.isDirectory()) {
         String list[] = f.list();
         for (int i = 0; i < list.length; i++) {
            process(name + f.separator + list[i]);
         }
      } else if (f.isFile()) {
         // parse content of f.getName()
      }
   }

I would think.

Arne
M.J. Dance - 30 Aug 2006 10:48 GMT
> How could one parse multiple files within a folder and its subfolders in
> search for a string, for instance?

You do it just like you described is: process all the files in all the
(sub)directories.

But I think this isn't a parsing problem. Is it a homework? Do you need code? ;-)
M.J. Dance - 01 Sep 2006 09:27 GMT
> Do you need code? ;-)

I guess not, then. And I wrote such a nice example. :-\
:-))))


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.