• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File Open/Save Operations in Swing Editor

 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have build using swing a text editor with menu's.
Now what i want is to open/save the files. For this purpose, I have used JFileChooser class dialogue and it's working fine. And now I have to perform open/save functions in it.
Would anybody help me or suggest me any example related to the above issue.
Thanks/kind regards
Rashid Ali
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can get the selected file to open with the file chooser. Then you can construct a FileInputStream from that file, read the content of the file and put it inside your TextArea:


For the Save feature, you just hae to adapt somewhat the code but you got the idea...
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
[This message has been edited by Valentin Crettaz (edited October 30, 2001).]
 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you really very much dear Valentin Crettaz for your suggestion and example. It really helped and now my application working fine which is in its early stage.
I would like to post here my code for the beginners like me for their understanding in such sort of problems:

Thanks for this forum.
Kind regards
Rashid Ali
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What if your file to save or open is an executable file. I have an application and I want to save the application and all the information it has generated. The application is in a JFrame so I can open the JFrame in a window but how do I read in the information? I am thinking I must use the command line to run the application but then I will have lost portability.
Is there a platform independent way to run an executable?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic