On Aug 7, 12:29 pm, Thomas Fritsch <i.dont.like.s...@invalid.com>
wrote:
> > How can I iterate the files inside a directory, like FindNextFile in
> > Win32.
[quoted text clipped - 4 lines]
> --
> Thomas
Because in case of a huge number of files, the list is very large and
memory consuming.
Do you know a way that I can iterate the files and get it one by one?
Thanks.
Andrew Thompson - 07 Aug 2007 12:51 GMT
>On Aug 7, 12:29 pm, Thomas Fritsch <i.dont.like.s...@invalid.com>
>wrote:
>> > How can I iterate the files inside a directory, like FindNextFile in
>> > Win32.
(T.F.)
>> Why not?
>Because in case of a huge number of files, the list is very large and
>memory consuming.
Over optimisation.
>Do you know a way that I can iterate the files and get it one by one?
Implement a NextFileFilter that extends FileFilter and
feed it to File.listFiles(nextFileFilter). But I expect the
JVM will ultimately fetch the entire file list before being
able to determine which is the 'next' file.

Signature
Andrew Thompson
http://www.athompson.info/andrew/
Christian - 07 Aug 2007 12:54 GMT
jaja schrieb:
> On Aug 7, 12:29 pm, Thomas Fritsch <i.dont.like.s...@invalid.com>
> wrote:
[quoted text clipped - 10 lines]
> Do you know a way that I can iterate the files and get it one by one?
> Thanks.
Are you really shure you need this kind of optimization?
usual directorys should have less than 10k files in them which should
mean less than 500 kiB of Memory, any problem with that?
if you have more than a 100k files per dir and need to have multiple
lists of such large directorys .. well.. first I would recommend you to
check the program that produced these horrible mess of files as this
could crash your filesystem .. or at least give it a hard time.
Christian