Win a copy of Terraform in Action this week in the Cloud 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

Saving a File

Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would i write code to save a file. Example, i want the code to be able to take the data just manipulated and save it to a file.
Ideally i want the screen to have a popup menu that can let you type in a file name and hit save...this will save your file to your destination. How would i code this saving process.
thank you in advance, Nikki
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To answer the first part of the question :
assume that you have your data stored in a string aString, if it is not, you can always find a way to map it into a string representation.
Now you can do :
RandomAccessFile rafOut = new RandomAccessFile("whateverPath" + File.separator + "whateverFileName", "rw");
}catch(IOException ex){
FileOutputStream fileOut = new FileOutputStream("whateverPath etc...");
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fileOut));
writer.write(aString, 0, aString.length());
}catch(IOException etc){
Now about the second question : see javax.swing.JFileChooser
good luck
[This message has been edited by Omar IRAQI (edited July 18, 2001).]
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic