本文整理汇总了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());
}