【发布时间】:2013-09-04 11:14:21
【问题描述】:
我有一个 DefaultStyledDocument,里面有一个格式化的文本。我还有一个函数,它用 Pattern-Matcher 分割内容(作为纯文本)。
我需要一个函数,它从拆分的输出中生成新的完整 DefaultStyledDocuments
DefaultStyledDocument doc = new DefaultStyledDocument();
Functions.loadRtfToDocument(rtfText, doc); //rtfText is a RTF-String
Pattern pattern = Pattern.compile("^((\\s*)•)", Pattern.MULTILINE);
Matcher matcher = pattern.matcher(plainText);
while(matcher.find()){
int start = matcher.start();
int end = matcher.end();
DefaultStyledDocument target = new DefaultStyledDocument();
//Fill the target with the styled text (from start to end)
}
【问题讨论】:
-
你看过jrtf吗?
-
嗨,不,我使用 RTFEditorKit... jrtf 可以将文档分成两部分吗? (例如,在列表元素处拆分)
标签: java swing split document rtf