Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / July 2006

Tip: Looking for answers? Try searching our database.

File listing perfomance issue

Thread view: 
ennio - 22 Jul 2006 16:13 GMT
Hi,
I cant reproduce the JFileChooser performance in directory listing.

When i retrieve the list of files inside a directory i need to know if
a file is a directory or not, to visualize it as a folder or not, for
instance. I know only this way in java:

File file = new File("z:/");
File[] files = file.listFiles();
for (int i = 0; i < 0; i++)
{
    if (files[i].isDirectory())
    {
        [...]
    } else {
        [...]
    }
}

The problem is that if the original directory is a mounted drive, the
thing can require ages to be accomplished.
In JFileChooser it doesn't take ages at all, it's instantaneous.

Was JFileChooser implemented using java or native code? Is there a way
to replace its perfomance in file listing with plain java?
I tried with a FileFilter, but it didn't solve anything to me.
Thanks
Thomas Hawtin - 22 Jul 2006 16:58 GMT
> I cant reproduce the JFileChooser performance in directory listing.
>
[quoted text clipped - 9 lines]
> to replace its perfomance in file listing with plain java?
> I tried with a FileFilter, but it didn't solve anything to me.

Why not look at the source? Most is in the JDK src.zip. The rest is
downloadable from https://tiger.dev.java.net/ .

I assume JFileChooser is using FileView.isTraversable.

http://download.java.net/jdk6/docs/api/javax/swing/filechooser/FileView.html#isT
raversable(java.io.File
)

You might just be seeing the result of caching. Have a look in
javax.swing.plaf.basic.BasicDirectoryModel.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

ennio - 22 Jul 2006 17:24 GMT
>You might just be seeing the result of caching. Have a look in
>javax.swing.plaf.basic.BasicDirectoryModel.

I really appreciated your reply, thanks.

>Unemployed English Java programmer
http://jroller.com/page/tackline/

Is it that hard to find a job in south england? Do they look for c#
more than java? Hope i am not OTing :-)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.