2015-03-13 50 views
0

我正在使用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); 

回答

0

這意味着您的java進程沒有足夠的內存來轉換該文件。

相關問題