Search code examples
javacharacter-encodingapplet

how to manage formatting of text when read a save file?


i have a java applet application in which i use rich text area . i write URDU the national language of PAKISTAN. i managed to do so with uni codes. the problem is, when i write urdu in text area and select a font and color for each line it do all of this but when i save this file using UTF-8 encoding and then open it again it shows all text formatted as i choose format of last line.

my requirement is to open file as it is saved. i mean each file should have same formatting as i done before saving.

I'm still suffering with this problem even after bounty can any one help! dated 07-06-2010.


Solution

  • See, when you actually format text using some font and color, it will generate some RTF/HTML code right? You should try to get the RTF/HTML of the text area so that all your formatting can be saved in a file.

    Basically all its a text file, so you need to get it with all code right?

    Check this link for RTF formatted text saving mechanism.

    Java JTextPane RTF Save

    Also check HTMLEditorKit for more info.

    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/text/html/HTMLEditorKit.html

    thanks.