• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing Documents

 
Mario Bonassin
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to write a save action that will write a Document from a JTextComponent to a txt file. I can't seem to figure it out. I've looked at the API and that hasn't gotten me anywhere.
any suggestions
Mario
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using a FileWriter
 
Mario Bonassin
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried all those and it doesn't write a whole document.
FileWriter(document) doesn't work.
Is there something I need to do to the Document of a JTextComponent to make it saveable. Do I need to convert the entire doc to a string and then write each string or can I somehow write the doc as a whole?
this is the document i'm talking about.
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/text/Document.html
 
Joe Ess
Bartender
Posts: 9320
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The documentation for Document directs you to this article on the Element interface. That article directs you to the API documentation for EditorKit which has methods for reading and writing to/from streams.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic