Home arrow static arrow Java Programming [Archive] - Get Directory Structure from JFileChooser?
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Get Directory Structure from JFileChooser?
This topic has 2 replies on 1 page.

Posts:1
Registered: 7/28/04
Get Directory Structure from JFileChooser?  
Jul 28, 2004 9:46 AM



 
Hi,

I am trying to see if there is a way I can just get the directory structure of the current file open, because I want to be able to have any window that opens open to the last used directory. I want to be able to store the directory information minus the file name and extension. Here is the code I am using to open a file. Is there a method to do this in the JFileChooser or File functions?
             JFileChooser fileChooser = new JFileChooser(); // The file-opening dialog              if(fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {                             File f = fileChooser.getSelectedFile();                 System.out.println(f);  // variable f contains the directory structure plus file name.                                // Set up a link to a file of the user's choice.                BufferedReader br = new BufferedReader(new FileReader(fileChooser.getSelectedFile()));

I am also trying to make this as OS independant as possible.
 

Posts:24,036
Registered: 2/3/03
Re: Get Directory Structure from JFileChooser?  
Jul 28, 2004 9:49 AM (reply 1 of 2)



 
System.out.println(f.getAbsoluteFile().getParent());
 

Posts:24,036
Registered: 2/3/03
Re: Get Directory Structure from JFileChooser?  
Jul 28, 2004 9:50 AM (reply 2 of 2)



 
If you find that helpful, don't forget the Dukes... ;o)
 
This topic has 2 replies on 1 page.