Java - Saving as RTF not supporting text alignment?
===

When I save a styled JTextPane as an RTF, and then re-open it, text alignment is not preserved. Here are my methods:

    private void saveAsRTF(File outfile) {
    RTFEditorKit rtfkit = new RTFEditorKit();
    StyledDocument doc = (StyledDocument) pane.getDocument();
    try {
        FileOutputStream fwi = new FileOutputStream(outfile);
        rtfkit.write(fwi, doc, 0, doc.getEndPosition().getOffset());
        fwi.close();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    } catch (BadLocationException ble) {
        ble.printStackTrace();
    }
    }

and (to open RTF)

     RTFEditorKit rtf = new RTFEditorKit();
      FileInputStream fi = new FileInputStream(j.getSelectedFile());
      rtf.read(fi, pane.getStyledDocument(), 0);

Finally, to align the text in the first place:

     SimpleAttributeSet attribs = new SimpleAttributeSet();  
    StyleConstants.setAlignment(attribs , StyleConstants.ALIGN_CENTER);  
    pane.setParagraphAttributes(attribs,true);