简体   繁体   English

文本文件扩展名

[英]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. 我正在寻找一种类似于notepad .txt的文本文件,但是可以保存斜体而不会丢失样式。 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 and 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. 我在JTextPane中混合了纯文本和斜体文本,并且需要一种文件格式将其保存到其中,而不会丢失斜体或创建所有这些奇特的标签-如果可能的话。

Any ideas...? 有任何想法吗...?

RTF is a textual format that preserves formatting, although sometimes it can be tricky to generate. RTF是一种保留格式的文本格式,尽管有时很难生成。 It's been around for ages so it's readable by Windows Wordpad and Word. 它已经存在了很长时间,所以它可以被Windows Wordpad和Word读取。

To find out how to mark text italic in RTF, enter it in WordPad, select formatting you like and save it as .rtf . 要了解如何在RTF中标记斜体文本,请在写字板中输入它,选择所需的格式并将其另存为.rtf After you've done so, change the extension to .txt and see the decoration code around your text. 完成后,将扩展名更改为.txt然后查看文本周围的修饰代码。 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. HTML比较简单,但是打开HTML文件通常会启动浏览器,而我相信您希望启动文本编辑器。

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. 在这种情况下,HTML更简单,更适合。

Please see examples of RTF and HTML being loaded in JTextPane . 请参阅JTextPane中加载的RTF和HTML示例

You tried .rtf? 你试过.rtf? Microsoft Word pad. 微软Word垫。 I think that is good solution for Windows OS. 我认为这是Windows操作系统的好解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM