1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
   |         // Creation d'un document HTML :
        HTMLEditorKit kitHtml = new HTMLEditorKit();
        Document docHtml = kitHtml.createDefaultDocument();
 
        // Lecture du fichier :
        InputStream inFile = new FileInputStream("c:/hello.html");
        try {
            kitHtml.read(inFile, docHtml, 0);
        } finally {
            inFile.close();
        }
 
        // Creation d'un kit RTF :
        RTFEditorKit kitRTF = new RTFEditorKit();
 
        // Sauvegarde du document HTML en RTF :
        OutputStream outFile = new FileOutputStream("c:/hello.rtf");
        try {
            kitRTF.write(outFile, docHtml, 0, docHtml.getLength());
        } finally {
            outFile.close();
        } | 
Partager