Yeah, that's what's going to happen. Locally it's going to be quick to get that file handle again. A network file system will have the "standard" problem of round trip latency time for any operations which can not be aggregated into one call.
Ironically, when you get a File[] from Java, the attributes probably come back to your machine in the OS objects, but arn't stored anywhere by Java. It just pulls the file names and stores them in the File objects. Each file.isDirectory() is a round trip to the server. I doubt the Sun would try to implement any caching into the File object simply because it might break too many things. If you call getDirectory() 1 min after creating the File object, the result could be wrong. So I understand how they can't really solve is because of the contract that the File class has. The only solution would be some kind of new API or extension. On Jan 7, 9:46 am, John Muir <[email protected]> wrote: > I think you are on to the correct explanation, at least from what I > read on the Sun/Bugs site. It seems to be related to caching the file > information. > > However, as the facts stand it's much slower over the network, so to > return to the original post - does anyone have a solution or > workaround? > > On Jan 7, 12:09 am, Christian Catchpole <[email protected]> > wrote: > > > > > Here is my "guess" as to what is happening (I had a quick look at the > > bug ticket but couldn't see an explanation). > > > And I haven't written this sort of code in C for a while, so this is > > an extra big guess. > > > When you get a dir list in Java it creates a list of File objects > > which are just paths to the file. Calling isDirectory() forces is to > > go back the the network because it doesn't have any kind of real > > handle on the OS object which represents the file. > > > In C, when you get a directory list, do you get a list of "handles to > > OS objects" which can be polled immediately for an attribute?
-- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
