[英]JTextpane does not save attributed text and icons in the file
我试图将 Java 文本窗格的文档另存为“rtf”文件,文档的内容已保存到文件中,但未保存上标和下标以及图标等属性
````java
StyledDocument docx =(DefaultStyledDocument) editor.getDocument();
RTFEditorKit kit = new RTFEditorKit();
System.out.println(kit.getContentType()) ;
int startPos = docx.getStartPosition().getOffset();
int docLen = docx.getLength();
File file = new File("E:\\file1.rtf");
BufferedOutputStream out =null ;
try {
out= new BufferedOutputStream(new FileOutputStream(file));
kit.write(out, docx,startPos ,docLen);
out.close();
}
catch (Exception ex) {
}
````
经过一些阅读,我发现 Java 文本包对 RTF 文件类型的支持并不完整,当您使用 TRFEditorkit 编写或读取文件时,您会得到纯文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.