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


Java EditorKit.write方法代码示例

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


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

示例1: saveFromKitToStream

import javax.swing.text.EditorKit; //导入方法依赖的package包/类
@Override
protected void saveFromKitToStream(StyledDocument doc, EditorKit kit, OutputStream stream)
        throws IOException, BadLocationException {
    
    if (guardedProvider != null) {
        Charset c = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
        Writer writer = guardedProvider.createGuardedWriter(stream, c);
        try {
            kit.write(writer, doc, 0, doc.getLength());
        } finally {
            writer.close();
        }
    } else {
        super.saveFromKitToStream(doc, kit, stream);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:BIEditorSupport.java

示例2: saveFromKitToStream

import javax.swing.text.EditorKit; //导入方法依赖的package包/类
@Override
protected void saveFromKitToStream(StyledDocument doc, EditorKit kit, OutputStream stream) throws IOException, BadLocationException {
    if (guardedProvider != null) {
        Charset c = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
        Writer writer = guardedProvider.createGuardedWriter(stream, c);
        try {
            kit.write(writer, doc, 0, doc.getLength());
        } finally {
            writer.close();
        }
    } else {
        super.saveFromKitToStream(doc, kit, stream);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:GuardedBlockTest.java

示例3: saveFromKitToStream

import javax.swing.text.EditorKit; //导入方法依赖的package包/类
/**
 * @inheritDoc
 */
@Override
protected void saveFromKitToStream(StyledDocument doc, EditorKit kit, OutputStream stream) throws IOException, BadLocationException {
    if (doc == null) {
        throw new NullPointerException("Document is null"); // NOI18N
    }
    if (kit == null) {
        throw new NullPointerException("Kit is null"); // NOI18N
    }
    
    Charset c = charsets.get(this.getDataObject());
    if (c == null) {
        c = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
    }
    FilterOutputStream fos = new FilterOutputStream(stream) {
        @Override
        public void close() throws IOException {
            flush();
        }
    };
    Writer w = new OutputStreamWriter (fos, c);
    try {
        kit.write(w, doc, 0, doc.getLength());
    } finally {
        w.close();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:DataEditorSupport.java

示例4: saveFromKitToStream

import javax.swing.text.EditorKit; //导入方法依赖的package包/类
/**
 * @inheritDoc
 */
@Override
protected void saveFromKitToStream(StyledDocument doc, EditorKit kit, OutputStream stream) throws IOException, BadLocationException {
    String foundEncoding = (String) doc.getProperty(DOCUMENT_SAVE_ENCODING);
    String usedEncoding = foundEncoding != null ? foundEncoding : UTF_8_ENCODING;
    final Charset c = Charset.forName(usedEncoding);
    final Writer w = new OutputStreamWriter(stream, c);
    try {
        kit.write(w, doc, 0, doc.getLength());
    } finally {
        w.close();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:HtmlEditorSupport.java

示例5: rtf2html

import javax.swing.text.EditorKit; //导入方法依赖的package包/类
public String rtf2html(final String rtf) {
	final JEditorPane p = new JEditorPane();
	p.setContentType("text/rtf");
	final EditorKit kitRtf = p.getEditorKitForContentType("text/rtf");
	try {
		kitRtf.read(new StringReader(rtf), p.getDocument(), 0);
		final Writer writer = new StringWriter();
		final EditorKit editorKitForContentType = p.getEditorKitForContentType("text/html");
		editorKitForContentType.write(writer, p.getDocument(), 0, p.getDocument().getLength());
		return writer.toString();
	} catch (IOException | BadLocationException e) {
		throw new RTF2HTMLException("Could not convert RTF to HTML.", e);
	}
}
 
开发者ID:TheConfusedCat,项目名称:msgparser,代码行数:15,代码来源:JEditorPaneRTF2HTMLConverter.java

示例6: saveFromKitToStream

import javax.swing.text.EditorKit; //导入方法依赖的package包/类
protected void saveFromKitToStream(StyledDocument doc, EditorKit kit, OutputStream stream)
throws IOException, BadLocationException {
    kit.write(new OutputStreamWriter(stream, dObj.getEncodingHelper().getEncoding()), doc, 0, doc.getLength());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:XmlMultiViewEditorSupport.java


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