Hello!
I need to read rtf file. I use JTextPane and RTFEditorKit, but I can't guess correct encoding... some characters aren't displayed properly.
This is the beginning of my sample rtf file:
{\rtf1\ansi\ansicpg1250\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1045\deflangfe1045{\fonttbl{\f0\froman\fcharset238\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f38\froman\fcharset0\fprq2 Times New Roman;}
and here is my code (I thought that encoding should be cp1250 but it's not working):
JTextPane editor = new JTextPane();
RTFEditorKit m_kit = new RTFEditorKit();
InputStream ins = new FileInputStream(new File("Koshmar.rtf"));
InputStreamReader in = new InputStreamReader(ins,"Cp1250");
StyledDocument m_doc = new DefaultStyledDocument(new StyleContext());
m_kit.read(in, m_doc, 0);
editor.setDocument(m_doc);
Another problem is that first I would like to find out in which encoding is given file and then read it using this encoding.