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. :-\
:-))))