一个属性声称在零之前开始,在-512!将其重置为零,并抱着最好的希望

  • 本文关键字:希望 属性 一个 -512 开始 java
  • 更新时间 :
  • 英文 :


当我阅读MS word文档Header(.doc)时,我得到了这个异常:

"A property claimed to start before zero, at -512! Resetting it to zero, and hoping for the best"

我使用这个库poi-scratchpad-3.2-final-20081019,我使用这个代码来阅读:

import java.io.*;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
public class ReadDocFile {
public static void main(String[] args) {
File file = null;
WordExtractor extractor = null ;
try {
   file = new File("c:\New.doc");
   FileInputStream fis=new FileInputStream(file.getAbsolutePath());
   HWPFDocument document=new HWPFDocument(fis);
   extractor = new WordExtractor(document);
   String [] fileData = extractor.getParagraphText();
   for(int i=0;i<fileData.length;i++){
     if(fileData[i] != null)
       System.out.println(fileData[i]);
   }
}
catch(Exception exep){}
  }
}

此错误是由poi文件引起的:

protected PropertyNode(int fcStart, int fcEnd, Object buf)
{
    _cpStart = fcStart;
    _cpEnd = fcEnd;
    _buf = buf;
    if(_cpStart < 0) {
        _logger.log(POILogger.WARN, "A property claimed to start before zero, at " + _cpStart + "! Resetting it to zero, and hoping for the best");
      _cpStart = 0;
    }
    //more code

正如您在代码中看到的,当_cpStart小于0时,记录器会创建此错误,在您的情况下为:-512。这意味着调用PropertyNode方法时fcStart=-512。

至于用512来称呼它:

512源于org.apache.poi.hwpf.model中的一个计算。CHPFormatedDiskPage,其中getStart(x)返回1536,fcMin为2048。

摘自:错误报告

创建HWPFDocument实例时会记录此警告,这是一个不会影响功能的已知错误(因为_cpStart设置为0)。

相关内容

最新更新