Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Working with directories in JFileChooser

843807Apr 27 2010 — edited May 5 2010
Ok as usual I do not want code done for me but a nudge in the right direction would be helpful.
Essentially I want to use a JFileChooser to select and iterate through a directory, if there is a directory inside that I need to open it and iterate through it as well. I know a recursive function will probably do me jsut fine however, I cannot seem to be able to get my JFileChooser to select the directory in such a was as to let me work with it.
Yes I do have the
JFileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
I currently have the ability to copy files, etc... with no problem. But have not been able to figure out how to select a directory and then iterate through it calling my copy functions and whatnot.
I can get the current directory just fine, I can return false from File.isDirectory when I have a file selected. Now how the heck do I declare a directory variable/object to work with? or is that the completely wrong approach?
no I do not have an sscce to post as I have not figured out any code for the directory functions at all.

I have read through the api and tutorials and did not see what I need nor has Google been much help. If one of you nice patient pro's could point me to the proper link to figure this out that would be great. or a very generic sample on how to select and manipulate a directory from JFileChooser. Please don't tell me it has to be done with a JTree as I will have to shoot myself in the both feet since that would require a rebuild of the entire project... lol Thanks in advance for your patience.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 2 2010
Added on Apr 27 2010
10 comments
722 views