This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

In JFileDialog how to use the save window

 
sushant prabhu
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Tanveer Rameez
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic