关于OpenOffice转换失败,源文件无法删除问题的解决办法
如何使用openOffice进行文档转化在次不做赘述,本文关注的是在OpenOffice转化失败的时候,并且提示源文件无法打开时的解决办法。当遇到如下问题时:
Caused by: org.artofsolving.jodconverter.office.OfficeException: could not load document: 测试.docx
at org.artofsolving.jodconverter.AbstractConversionTask.loadDocument(AbstractConversionTask.java:99)
at org.artofsolving.jodconverter.AbstractConversionTask.execute(AbstractConversionTask.java:59)
at org.artofsolving.jodconverter.office.PooledOfficeManager$2.run(PooledOfficeManager.java:80)
... 6 more
你会发现无法删除名为“测试.docx”的文件(至于为什么需要删除,因人而异吧)。原因分析如下:(以下为OpenOffice中,jodconverter-core-3.0-beta-4-sources.jar源码)
public void execute(OfficeContext context) throws OfficeException {
XComponent document = null;
try {
document = loadDocument(context, inputFile);
modifyDocument(document);
storeDocument(document, outputFile);
} catch (OfficeException officeException) {
throw officeException;
} catch (Exception exception) {
throw new OfficeException("conversion failed", exception);
} finally {
if (document != null) {
XCloseable closeable = cast(XCloseable.class, documen