Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: java.io.File Date: Tue, 6 Dec 2011 09:23:12 -0800 (PST) Organization: http://groups.google.com Lines: 39 Message-ID: <9355143.259.1323192192716.JavaMail.geo-discussion-forums@prgk20> References: <1754083.312.1322839502470.JavaMail.geo-discussion-forums@prjr26> <4ed8fc62$0$10730$426a74cc@news.free.fr> <3749375.667.1322863677698.JavaMail.geo-discussion-forums@preu18> <4ede2a90$0$21836$426a74cc@news.free.fr> 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 1323192283 18428 127.0.0.1 (6 Dec 2011 17:24:43 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 6 Dec 2011 17:24:43 +0000 (UTC) In-Reply-To: <4ede2a90$0$21836$426a74cc@news.free.fr> 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:10563 Mayeul wrote: > Lew wrote: >> How, then, do calls like 'File#canRead()', 'canWrite()', 'createNewFile()', >> 'createTempFile()', 'delete()', 'exists()', 'getFreeSpace()', >> 'isDirectory()', 'isFile()', 'list()', 'listFiles()', 'mkdir()', 'mkdirs()', >> 'setReadable()', 'setReadOnly()' and 'setWritable()' work? > > I would have said, by merely looking up files or trying to create files > of the pathname the instance represents. But maybe my poor English > communication skills are getting in the way. The word "merely" is a dodge. "Looking up" and "trying to create" involve system calls to the OS. The 'File' object has methods that affect and report on the state of the real world, not just the abstract pathname, so obviously in order to do that it has to interact with system calls. Perhaps they aren't file descriptors through which the instance asks a directory what files it lists, or by which it creates a temporary file, but they sure as heck are resources that have to be released. >> Maybe those operations don't use file descriptors, but they do use OS >> filesystem resources. > > Those operations obviously do, but it seemed to me they were loosely > tied to the internal state of java.io.File instances. And therefore ...? Clearly they are tied to the 'File' instance state, and not "loosely", either. That is just as clear as that these operations interact with the file system and therefore use OS resources. It is puzzling to me how anyone can make the argument that an object is independent of the file system while acknowledging that it interacts with the file system. Sure, 'File' doesn't have a 'close()' method, but it has operations that open things. One assumes that such operations are RAII, but one also recognizes that this is an assumption. -- Lew