Пытаюсь из одного rtf файла записать в другой, но при попытке записи выдаёт IOException :RTF is a 8-bit format. Может я в неправильной кодировке пишу?
| Код | import javax.swing.text.*; import javax.swing.text.rtf.*; import java.io.*; public class myRTF { public static void main(String args[]) throws UnsupportedEncodingException, FileNotFoundException, IOException{ InputStream in = new FileInputStream(args[0]); OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(args[1])); RTFEditorKit rtf=new RTFEditorKit(); DefaultStyledDocument doc = new DefaultStyledDocument(); try { rtf.read(in, doc, 0); rtf.write(out,doc,0,doc.getLength()); } catch (Exception e) { System.out.println(e); } out.close(); } }
|
|