Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: A strange behaviour of a File property Date: Sun, 13 Nov 2011 22:00:07 -0800 (PST) Organization: http://groups.google.com Lines: 26 Message-ID: <19328983.549.1321250407838.JavaMail.geo-discussion-forums@prew38> References: <5980efbc-9010-4145-b886-fe106c5ac2d5@c18g2000yqj.googlegroups.com> <2011111400244576638-angrybaldguy@gmailcom> Reply-To: comp.lang.java.programmer@googlegroups.com NNTP-Posting-Host: 173.164.137.214 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1321250502 14223 127.0.0.1 (14 Nov 2011 06:01:42 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 14 Nov 2011 06:01:42 +0000 (UTC) In-Reply-To: <2011111400244576638-angrybaldguy@gmailcom> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.164.137.214; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9949 Owen Jacobson wrote: > Eric Sosman said: ... >> Even better is to forgo the silly string-bashing and let File >> figure it out: >> >> File parentDir = ...; >> File childFile = new File(parentDir, "child"); > > You don't need that, either, if all you're doing is enumerating > directory contents like the OP. File exposes a method for obtaining the > entries of a directory *as File objects* already, so reconstructing > File objects from the base names and parent directory is pretty much > wasted effort. > > Have a look at the listFiles() method. > > -o When quoting him, you left out the part of Eric's post that said: > (In the O.P.'s specific case, using listFiles() instead of list() > would simplify things a good deal.) -- Lew