File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JFileChooser and network share Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFileChooser and network share" Watch "JFileChooser and network share" New topic

JFileChooser and network share

Andreas Pax Lück

Joined: Nov 04, 2009
Posts: 18
Hi friends!

I need to display network shares in a JFileChooser. It's possible to show the network shares of the concerning host via the network button. But I'd also like to display them hardcoded by invokation of:

The JFileChooser doesn't do nothing in this case. If I do specify the explicit share ressource it works:

I don't know the shared folders. So, I want to show the list of all shared folders of the concerning host. Is this impossible?

Best regards


"Wenn man irgendwann mal von allen akzeptiert wird, dann weiß man, dass man irgendwas falsch gemacht hat."
Excerpt by: Mr. Weidner
Rob Spoor

Joined: Oct 27, 2005
Posts: 20275

I've tried with my own machine, and if I create a File around an actual share and call its exists() method, it returns true. If I create a File around the network host only (e.g. new File("\\\\hostname")), exists() returns false. As such, is not the means to retrieving these. That also means that JFileChooser can't help you out, since it uses in the background.

How To Ask Questions How To Answer Questions
Andreas Pax Lück

Joined: Nov 04, 2009
Posts: 18
ok, that's really bad.

thanks for your help.

best regards

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10825

If you are using Windoze, you might find this thread useful
Some more info here

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Andreas Pax Lück

Joined: Nov 04, 2009
Posts: 18
these are interesting information. does the nethood location also have a common caption? i realized that its name isn't "NetHood" on systems with a different language than english.
I agree. Here's the link:
subject: JFileChooser and network share
It's not a secret anymore!