text file extensions
I am looking for a type of text file like notepad .txt, but one that italics can be saved into without loosing the style. The file dosn't need to display the italics just as long as the lines of text can be loaded out into a different file or program console with the italics back in place.
I have a mixture of plain a开发者_如何学JAVAnd italic text in a JTextPane and I need a file format to save it into without losing the italic or creating all these fancy tags - if possible.
Any ideas...?
RTF is a textual format that preserves formatting, although sometimes it can be tricky to generate. It's been around for ages so it's readable by Windows Wordpad and Word.
To find out how to mark text italic in RTF, enter it in WordPad, select formatting you like and save it as .rtf
. After you've done so, change the extension to .txt
and see the decoration code around your text. You can replicate later it in your app.
HTML is simpler but opening HTML file would usually start the browser, whereas I believe you want text editor to start.
UPDATE:
From your clarifications I understand the user is not to read the file, it will only be read/written by your program. In this case HTML is much simpler and better suited.
Please see examples of RTF and HTML being loaded in JTextPane
.
You tried .rtf? Microsoft Word pad. I think that is good solution for Windows OS.
精彩评论