File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes directory structure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "directory structure" Watch "directory structure" New topic

directory structure

kalai sundar
Ranch Hand

Joined: May 25, 2005
Posts: 69
my problem is

int fc=FileChooser.showOpenDialog(this);
String str=fil.getAbsolutePath();
when i use the above mention code, i am editing the directory path as for eg
e:\sample\new.class.But i don't want like that, i want to edit as e:\sample, But i coudn't vat should i do. plz hepl me

Joe Ess

Joined: Oct 29, 2001
Posts: 9045

So you want to select a directory? Looking at the Java API documentation for javax.swing.JFileChooser, you'll see there's a method setFileSelectionMode:

public void setFileSelectionMode(int mode)

Sets the JFileChooser to allow the user to just select files, just select directories, or select both files and directories. The default is JFilesChooser.FILES_ONLY.

mode - the type of files to be displayed:

* JFileChooser.FILES_ONLY

IllegalArgumentException - if mode is an illegal file selection mode
See Also:

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: directory structure