• Post Reply Bookmark Topic Watch Topic
  • New Topic

File Open/Save Operations in Swing Editor

 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • 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
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Tracey Currier
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!