From: Eric Sosman on
On 2/4/2010 3:44 PM, Rhino wrote:
> "Eric Sosman"<esosman(a)ieee-dot-org.invalid> wrote in message
> news:hkf774$jeg$1(a)news.eternal-september.org...
>> On 2/4/2010 2:13 PM, Rhino wrote:
>>> Can anyone point me to an example of Java code that searches for all the
>>> files within a given Windows directory (and doesn't recurse into
>>> subdirectories) and then stores the file names in some kind of array or
>>> collection? For example, if my directory was c:\foo, it would store a
>>> list
>>> of all the files found in the foo directory.
>>>
>>> I've lost most of my old code examples due to a hard drive crash and feel
>>> sure that this kind of code must have been done umpteen times before.
>>> I'll
>>> write it from scratch if I have to but I'm hoping some kind soul can
>>> point
>>> me to an example or just post it directly....
>>
>> String[] names = new File("c:\\foo").list();
>>
>> I hope your new drive has enough room for this.
>>
>> --
>> Eric Sosman
>> esosman(a)ieee-dot-org.invalid
>
> I'm _REALLY_ rusty on my Java - haven't touched it in almost 4 years and I
> feel like I've forgotten almost everything. For some reason, I thought that
> was going to be more involved that it was.

One thing you appear to have forgotten in the existence
of something called "Javadoc" ...

(Another is that quoting Usenet signatures is frowned
upon. Have a care, or Lew will chastise you!)

--
Eric Sosman
esosman(a)ieee-dot-org.invalid
From: Roedy Green on
On Thu, 04 Feb 2010 14:29:06 -0500, Eric Sosman
<esosman(a)ieee-dot-org.invalid> wrote, quoted or indirectly quoted
someone who said :

>
> String[] names = new File("c:\\foo").list();

that is a fairly small list. list does not recurse for you.
--
Roedy Green Canadian Mind Products
http://mindprod.com

You can�t have great software without a great team, and most software teams behave like dysfunctional families.
~ Jim McCarthy
From: Eric Sosman on
On 2/5/2010 11:30 AM, Roedy Green wrote:
> On Thu, 04 Feb 2010 14:29:06 -0500, Eric Sosman
> <esosman(a)ieee-dot-org.invalid> wrote, quoted or indirectly quoted
> someone who said :
>
>> String[] names = new File("c:\\foo").list();
>
> that is a fairly small list. list does not recurse for you.

The O.P. asked for "an example of Java code that searches
for all the files within a given Windows directory (and doesn't
recurse into subdirectories)."

Harrumph.

--
Eric Sosman
esosman(a)ieee-dot-org.invalid
From: Arne Vajhøj on
On 05-02-2010 11:50, Eric Sosman wrote:
> On 2/5/2010 11:30 AM, Roedy Green wrote:
>> On Thu, 04 Feb 2010 14:29:06 -0500, Eric Sosman
>> <esosman(a)ieee-dot-org.invalid> wrote, quoted or indirectly quoted
>> someone who said :
>>
>>> String[] names = new File("c:\\foo").list();
>>
>> that is a fairly small list. list does not recurse for you.
>
> The O.P. asked for "an example of Java code that searches
> for all the files within a given Windows directory (and doesn't
> recurse into subdirectories)."
>
> Harrumph.

Reading what he comment on does not seem to be Roedy's
strong side.

Arne

From: Roedy Green on
On Fri, 05 Feb 2010 11:50:22 -0500, Eric Sosman
<esosman(a)ieee-dot-org.invalid> wrote, quoted or indirectly quoted
someone who said :

> The O.P. asked for "an example of Java code that searches
>for all the files within a given Windows directory (and doesn't
>recurse into subdirectories)."
>
> Harrumph.

Sorry about that. I saw the word "recurse" and thought -- he needs
help with recursion. I could see someone asking for help with
recursion but not with File.list which is completely straightforward.

Most newbie questions to me read like gibberish, so I tend just to
skim them, even when they are coherent. I pick out a few keywords and
guess what the user is actually asking. Most of you are much better at
interpreting them literally.

I am more interested in the general audience than the particular
newbie, so it is not of paramount importance that I answer their
question specifically, just that I put out something useful on the
general topic. I figure a newbie asking a particular question is
probably lacking in background. With background, they can often
answer their own question. I generally frown on spoon feeding. I
like to make the newbie stretch a bit.


--
Roedy Green Canadian Mind Products
http://mindprod.com

Every compilable program in a sense works. The problem is with your unrealistic expections on what it will do.