我正在使用java中的XHTML转换器将DOCX文件转换为HTML文件。即我们正在将HTML文件下载到临时路径,然后我在浏览器中加载该HTML文件。但转换之前它给出了一个错误:内存不足错误 - 超出GC开销限制
Error 404 not found
(浏览器)和
java.lang.OutOfMemoryError: GC overhead limit exceeded
(控制台)。
我在下面的代码中的“XWPFDocument document = new XWPFDocument(in);”行中出现错误。
String root = finalDestinationPath;
int lastIndex = sDocPath.lastIndexOf(File.separator);
String sFileName = sDocPath.substring(lastIndex + 1, sDocPath.length());
String fileNameWithOutExt = FilenameUtils.removeExtension(sFileName);
String fileOutName = root + File.separator + fileNameWithOutExt + ".html";
InputStream in = new FileInputStream(new File(sDocPath));
XWPFDocument document = new XWPFDocument(in);
XHTMLOptions options = XHTMLOptions.create();// .indent(4);
String sLocalSystemImagePath = finalDestinationPath + File.separator+"images"+File.separator;
File imageFolder = new File(sLocalSystemImagePath);
options.setExtractor(new FileImageExtractor(imageFolder));
// URI resolver
String localHostImagePath = downloadImagePath + File.separator+"images"+File.separator;
FileResolver fileURIResolver = new FileResolver(new File(localHostImagePath));
options.URIResolver(fileURIResolver);
out = new FileOutputStream(new File(fileOutName));
XHTMLConverter.getInstance().convert(document, out, options);
2015-03-13
Rashmi