parsing multiple files

P

Peter Parker

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.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Peter said:
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);
}
} else if (f.isFile()) {
// parse content of f.getName()
}
}

I would think.

Arne
 
M

M.J. Dance

Peter said:
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? ;-)
 
Joined
Oct 3, 2006
Messages
2
Reaction score
0
Hi M. J. Dance,

I'm facing a similar problem and would love to know whether your code (solution) is still available. If it is, I will be most grateful.

Thanks
 
Joined
Oct 3, 2006
Messages
2
Reaction score
0
M.J. Dance said:
M.J. Dance wrote:
> Do you need code? ;-)


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

Please let me have the code for the example you created.

Many thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,082
Members
48,773
Latest member
Kaybee

Latest Threads

Top