Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

In JFileDialog how to use the save window

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
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
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
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);
Squanch that. And squanch this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic