Re: How to save/load JTextPane to/from file?



On Tue, 22 Jan 2008 18:55:56 -0800 (PST), hiwa <HGA03630@xxxxxxxxxxx>
wrote, quoted or indirectly quoted someone who said :

. How to save it onto a file and load back it
onto a new JTextPane?

do a getText and save that the way you would any other string,
perhaps with a Writer, a ObjectStream, or a DataOutputStream.

see http://mindprod.com/applet/fileio.html
for sample code.

Don't try to serialize the JTextPane itself. You won't necessarily be
able to read it back under a different version of Java.
--
Roedy Green, Canadian Mind Products
The Java Glossary, http://mindprod.com
.



Relevant Pages

  • Editor Kit mystery? I dont get it.
    ... I build a JTextPane which is editable, save it to a file, and load it ... back after which it's editing behavior is completely whacked out. ... Then I save the contents as a string put into a larger XML file like ... writer = new CharArrayWriter; ...
    (comp.lang.java.programmer)
  • Re: A Simple jTextPane Problem
    ... How do I code a jTextPane so that when a user clicks on (let say the ... JTextPane textPane1 = new JTextPane; ... public static void main(final String[] args) ... ClickedPaneListener(JTextPane fromPane, JTextPane toPane) { ...
    (comp.lang.java.beans)
  • Linefeed und Carriage Return in JTextPane - gewollt bzw. wie verhindern?
    ... verarbeiten. ... Der String, den ich mit getText() bekomme enthält CR+LF. ... Warum taucht also im Text des JTextPane 'A'LFCR'B' auf? ...
    (de.comp.lang.java)
  • Re: JTextPane: find the length of invisible text ?
    ... I'm searching a way to find the length of the text in a JTextPane ... Or you could directly try rendering the string onto an offscreen buffer ... Oliver ...
    (comp.lang.java.gui)
  • Re: Array to nice table presentation
    ... >> However, it is extremely slow. ... Setting the content of the JTextPane or ... > StringBuffer and not just appending to a String instead. ...
    (comp.lang.java.programmer)