当前位置: 首页>>代码示例>>Java>>正文


Java RTFEditorKit.createDefaultDocument方法代码示例

本文整理汇总了Java中javax.swing.text.rtf.RTFEditorKit.createDefaultDocument方法的典型用法代码示例。如果您正苦于以下问题:Java RTFEditorKit.createDefaultDocument方法的具体用法?Java RTFEditorKit.createDefaultDocument怎么用?Java RTFEditorKit.createDefaultDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.rtf.RTFEditorKit的用法示例。


在下文中一共展示了RTFEditorKit.createDefaultDocument方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RTF2TXT

import javax.swing.text.rtf.RTFEditorKit; //导入方法依赖的package包/类
public static final String RTF2TXT(String Str)
throws IOException, BadLocationException
  {
    if (Str != null && Str.startsWith("{\\rtf1") == true)
      {
        // There is a "questionable" bug in the RTF-to-Text routine in the Java library. With tables, text in
        // adjacent cells are concatenated without any
        // spacing. So, for example, a table with a cell containing "abc" followed by another call containing "123",
        // after conversion, you'll get "abc123".
        // With this hack, we capture the RTF cell delimiter "\cell$" and replace it with ". \cell$". This will
        // separate text in cells from other text and will
        // allow text processing to give better results.
        Str = RTF_CELL_PATTERN.matcher(Str).replaceAll(". $0");
        RTFEditorKit RTF = new RTFEditorKit();
        Document doc = RTF.createDefaultDocument();
        RTF.read(new StringReader(Str), doc, 0);
        Str = doc.getText(0, doc.getLength());
      }
    return Str;
  }
 
开发者ID:CapsicoHealth,项目名称:Tilda,代码行数:21,代码来源:TextUtil.java

示例2: installWidgetsFromRTF

import javax.swing.text.rtf.RTFEditorKit; //导入方法依赖的package包/类
/**
 * @param db The {@link Dragboard} containing the dragged data.
 * @param selection_tracker Used to get the grid steps from its model to be
 *            used in offsetting multiple widgets.
 * @param widgets The container of the created widgets.
 */
private static void installWidgetsFromRTF (
    final DragEvent event,
    final SelectedWidgetUITracker selection_tracker,
    final List<Widget> widgets
) {

    final Dragboard db = event.getDragboard();
    final String rtf = db.getRtf();
    final RTFEditorKit rtfParser = new RTFEditorKit();
    final Document document = rtfParser.createDefaultDocument();

    try {
        rtfParser.read(new ByteArrayInputStream(rtf.getBytes()), document, 0);
        installWidgetsFromString(event, document.getText(0, document.getLength()), selection_tracker, widgets);
    } catch ( Exception ex ) {
        logger.log(Level.WARNING, "Invalid RTF string", ex);
    }

}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:26,代码来源:WidgetTransfer.java

示例3: parseContent

import javax.swing.text.rtf.RTFEditorKit; //导入方法依赖的package包/类
@Override
protected void parseContent(StreamLimiter streamLimiter, LanguageEnum lang)
		throws IOException {
	RTFEditorKit rtf = new RTFEditorKit();
	Document doc = rtf.createDefaultDocument();
	try {
		ParserResultItem result = getNewParserResultItem();
		rtf.read(streamLimiter.getNewInputStream(), doc, 0);
		result.addField(ParserFieldEnum.content,
				doc.getText(0, doc.getLength()).trim());
	} catch (BadLocationException e) {
		throw new IOException(e);
	}
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:15,代码来源:RtfParser.java

示例4: readFile

import javax.swing.text.rtf.RTFEditorKit; //导入方法依赖的package包/类
public static String readFile(String url) {
	try {
		byte[] array = new byte[4096];
		RTFEditorKit rtfParser = new RTFEditorKit();
		Document document = rtfParser.createDefaultDocument();
		rtfParser.read(new URL(url).openStream(), document, 0);
		return document.getText(0, document.getLength());
	} catch (Exception e) {
	}
	return null;
}
 
开发者ID:uzzaco2002,项目名称:secri,代码行数:12,代码来源:DownloadHelper.java


注:本文中的javax.swing.text.rtf.RTFEditorKit.createDefaultDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。