aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes In JFileDialog how to use the save window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "In JFileDialog how to use the save window " Watch "In JFileDialog how to use the save window " New topic
Author

In JFileDialog how to use the save window

sushant prabhu
Ranch Hand

Joined: Mar 22, 2001
Posts: 66
I have used the open window with JFileDialog which gives me the opendialog , how do i use the save dialog where the user can type in his text & save the file with a name of his choice


Sushant Prabhu<br />SCJP2<br />SCWCD<br />OCA9i
Tanveer Rameez
Ranch Hand

Joined: Dec 11, 2000
Posts: 158
hi
I won't describe in details. I think you meant JFileChooser when u said JFiledialog. The JFileChooser will simply return the absolute path of the folder and the filename . You will have to do the saving yourself, just like you read the file after you open the open dialog of the JFileChooser and get the name of the file.
[code]
JFileChooser filechooser=new JFileChooser();
if( ImagerGlobal.ImageFileChooser.showOpenDialog(this)==JFileChooser.APPROVE_OPTION)
{
String absolutefilename= filechooser.getSelectedFile().getAbsolutePath());
File file=new File(absolutefilename);
FileInputStream fis=new FileInputStream(file);
//now save the data into this file input stream
//and then close the file input stream
}
hope this helps
regards
Tanveer


Author of JPhotoBrush Pro (www.jphotobrushpro.com)
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Have you looked at the tutorial from Sun. Here is a line directly from it. You can get there by clicking the how to use link in the API.
int returnVal = fc.showSaveDialog(FileChooserDemo.this);
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: In JFileDialog how to use the save window