Example usage for javax.swing.text.rtf RTFEditorKit write

List of usage examples for javax.swing.text.rtf RTFEditorKit write

Introduction

In this page you can find the example usage for javax.swing.text.rtf RTFEditorKit write.

Prototype

public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException 

Source Link

Document

Write content from a document to the given stream as plain text.

Usage

From source file:com.hexidec.ekit.EkitCore.java

public String getRTFDocument() throws IOException, BadLocationException {
    StyledDocument doc = (StyledDocument) (jtpMain.getStyledDocument());
    StringWriter strwriter = new StringWriter();
    RTFEditorKit rtfKit = new RTFEditorKit();
    rtfKit.write(strwriter, doc, 0, doc.getLength());
    return strwriter.toString();
}

From source file:com.hexidec.ekit.EkitCore.java

/**
 * Method for saving text as an RTF document
 *//*from www  .  java 2 s .  co  m*/
public void writeOutRTF(StyledDocument doc, File rtfFile) throws IOException, BadLocationException {
    FileOutputStream fos = new FileOutputStream(rtfFile);
    RTFEditorKit rtfKit = new RTFEditorKit();
    rtfKit.write(fos, doc, 0, doc.getLength());
    fos.flush();
    fos.close();
    refreshOnUpdate();
}