文件过早结束java_java – 过早结束文件异常

我正在尝试解析现有的xhtml文件,以将其他正文内容添加到该文件中.我使用以下代码:

首先,我正在阅读Jsoup中的身体,我正在尝试将其放入Xhtml文件中

Document doc = Jsoup.parse(readFile, "UTF-8");

Elements content = doc.getElementsByTag("body");

try {

Document document=null;

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

// Create the builder and parse the file

document = (Document)factory.newDocumentBuilder().parse(finalFile);

//document.getElementsByTagName("body")append(content.toString());

//document=parserXML(finalFile);

document.getElementsByTag("body").append(content.toString());

} catch (SAXException e) {

System.out.println("SAXException>>>>>>");

e.printStackTrace();

} catch (ParserConfigurationException e) {

System.out.println("in parser configuration Exception block>>>>>>");

e.printStackTrace();

}

但我得到以下例外:

[Fatal Error] ResultParsedFile.html:1:1: Premature end of file.

org.xml.sax.SAXParseException: Premature end of file.

at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)

at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)

at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)

at com.converter.typeconverter.EmailTypeConverter.readHTML(EmailTypeConverter.java:101)

at com.converter.typeconverter.EmailTypeConverter.callTika(EmailTypeConverter.java:64)

at com.converter.master.ApplicationMain.main(ApplicationMain.java:64)

请帮助我解决这个问题……

提前致谢…

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值