當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。