Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

data saving question

 
Code Monk
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My scenario is this: I want to save the contents of a JTextArea to a file. If possible, I'd like to be able to have bold, italics, and underlined text in that JTextArea as well, and be able to save and restore it into my Java program. I'm not exactly sure the best way to do this. Serialization? XML Serialization? Or some other way I don't know about.
Perhaps someone could point me in the right direction? And if you need more information as to what I'm trying to do, or why, let me know.
Thanks,
Sean
 
Joe Ess
Bartender
Pie
Posts: 9258
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTextArea just displays plain text. You use JEditorPane or JTextPane to display formatted text. They can also read plain text, HTML or RTF files, so take your pick as to the on-disk representation. They use a EditorKit to do the actual reading/writing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic