• Post Reply Bookmark Topic Watch Topic
  • New Topic

JFileChooser : Does any one know??  RSS feed

 
zoe goddard
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a JFileChooser, I've got a filter on it that only checks the filename extension. I've noticed that when it looks at the filenames in a directory it goes way slower in directories that contain larger sized files. I don't understand why this would happen, I should only be dealing with the filenames, the size of the file they're attached to shouldn't have any impact ... should it?
Does anyone know why this happens ?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Offhand, I agree with your analysis and don't see any reason why the filter should be any slower in directories with large files. (Maybe there's some strange OS issue here?) It might be useful to see your FileFilter to see if it's doing something strange.
 
zoe goddard
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here it is .... see anything ??
( I noticed this thing removes indentation )
[I put in [ CODE ] tags to fix that - Jim]

[ July 23, 2002: Message edited by: Jim Yingst ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see anything ??
No, it seems pretty straightforward. Kinda hard to imagine the JVM getting lost for any reason. Very strange. Perhaps others have ideas?
 
John Smith
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I seem to recall reading about this problem somewhere else. Apparently, the call to isDirectory() gets slower and slower the more (bigger?) files there are in a directory. Someone put forth the idea that the JVM is using inefficient native Windows (I'm assuming you're running Windows here) calls to implement isDirectory() and that there exists faster calls which can be used instead. He implemented his own native method using JNI and he said it was orders of magnitudes faster.
What happens if you remove the call to isDirectory()? Is it any faster?
 
zoe goddard
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's difficult to tell if its any quicker or not, with out that isDirectory(), navigation becomes a bit more difficult.
This could be why its slows down... I'm not sure.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, as an experiment you could make use of the fact that directories in Windows usually don't have a . in them, while files most always do:

This isn't as robust as it probably should be, but it might work well enough for your needs. At least, it should work most of the time, enough to see if the isDirectory() is really the problem.
[ July 25, 2002: Message edited by: Jim Yingst ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!