get all html as a String from HTMLDocument

前端 未结 2 1986
执念已碎
执念已碎 2021-01-05 03:43

Im coding in Java..

Does anyone know how i can get the content of a javax.swing.text.html.HTMLDocument as a String? This is what i´ve got so far...

         


        
2条回答
  •  时光取名叫无心
    2021-01-05 04:25

    StringWriter writer = new StringWriter();
    kit.write(writer, doc, 0, doc.getLength());
    String s = writer.toString();
    

提交回复
热议问题