Help coderanch get a
new server
by contributing to the fundraiser
  • 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 save and display in Swing

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to display the contents of the file on my local drive on a TextArea or TextPane when the user selects a file using FileChooser. Later the contents of the TextArea are read and few changes are made. I want to then get the modified contexts from the TextArea/TextPane component and save it into another using Swings. How do I do that

Reg
thomas
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java.io.FileReader
java.io.FileWriter

read up on those two API's for starters to read/write files.

You can build a StringBuilder or StringBuffer to setText() of the javax.swing.JTextArea

Those are some ideas to get you started...
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For reading/writing files, the following tips may help:

Reading Text from a File
http://www.java-tips.org/java-se-tips/java.io/reading-text-from-a-file.html

Writing to a File
http://www.java-tips.org/java-se-tips/java.io/writing-to-a-file.html
[ July 21, 2006: Message edited by: Casper Maxwell ]
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic