本文整理匯總了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);
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
}
示例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());
}