dcsimg
Opening a file using a file chooser
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ed_wrede
Posted On:   Monday, July 5, 2004 04:59 AM

Hi
Thanks for the help that you guys have given me over the last few months!
Im stuck yet again, this time with the filechooser component.
What i need to do is "open" a text file (i just need to pass the file path to a method of mine)now everythings fine when i key in the destination path directly but when i use the filechooser i dont know how to get the file path, i thought about using the GetSelectedFile method that is part of jfilechooser but it returns a file not a string.
So basically i need to pass a path in string form to a method using a filechooser!
If anyone can help id greatly appreciate it!
Thanks
Ed

Re: Opening a file using a file chooser

Posted By:   Benjamin_Toso  
Posted On:   Thursday, July 15, 2004 08:09 AM

File[] sFiles;

sFiles = myFileChooser.getSelectedFiles();



Once you have the File that you want use



File myFile = sFiles[x]; //x==whichever array index

myFile.getName();


and


myFile.getPath();


or whatever

Re: Opening a file using a file chooser

Posted By:   Anonymous  
Posted On:   Wednesday, July 7, 2004 02:48 AM

I think you´ll find a very interisting method in the File class :).
About | Sitemap | Contact