You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Amrun <Am...@gmx.at> on 2004/02/14 14:48:56 UTC

Exception at getting word content

Hi,

I've a problem using POI with java. 
Sometimes when I want to open a worddoc to get its content it doesn't work.
I get a NullPointerException looking like this one: 

java.lang.NullPointerException
	at org.apache.poi.hdf.extractor.Utils.convertBytesToShort(Utils.java:83)
	at
org.apache.poi.hdf.extractor.StyleSheet.doCHPOperation(StyleSheet.java:212)
	at
org.apache.poi.hdf.extractor.StyleSheet.uncompressProperty(StyleSheet.java:721)
	at
org.apache.poi.hdf.extractor.StyleSheet.uncompressProperty(StyleSheet.java:601)
	at
org.apache.poi.hdf.extractor.WordDocument.addParagraphContent(WordDocument.java:1086)
	at
org.apache.poi.hdf.extractor.WordDocument.createParagraph(WordDocument.java:978)
	at
org.apache.poi.hdf.extractor.WordDocument.addBlockContent(WordDocument.java:912)
	at
org.apache.poi.hdf.extractor.WordDocument.writeSection(WordDocument.java:717)
	at org.apache.poi.hdf.extractor.WordDocument.<init>(WordDocument.java:247)
	at usertool.LoadWordDoc.load(LoadWordDoc.java:45)
	at gui.UserTool.bOpen_actionPerformed(UserTool.java:372)
	at
gui.AdministrationTool_bOpen_actionAdapter.actionPerformed(UserTool.java:567)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
	at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
	at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
	at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
	at java.awt.Component.processMouseEvent(Component.java:5100)
	at java.awt.Component.processEvent(Component.java:4897)
	at java.awt.Container.processEvent(Container.java:1569)
	at java.awt.Component.dispatchEventImpl(Component.java:3615)
	at java.awt.Container.dispatchEventImpl(Container.java:1627)
	at java.awt.Component.dispatchEvent(Component.java:3477)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
	at java.awt.Container.dispatchEventImpl(Container.java:1613)
	at java.awt.Component.dispatchEvent(Component.java:3477)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
	at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
	at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

On some document it works without any problems, but on some specific ones it
just doesn't work. I can't find any equality in the word docs on which it
doesn't work. Maybe someone of you has had a similar problem before and knows
why this exception appears?!

Here is a code example with which I'm trying to get the content of the word
doc: 

try {
      fis = new FileInputStream(worddoc);  // worddoc is the word-file
      doc = new WordDocument(fis);

      doc.openDoc(); //open the document

      swriter = new StringWriter(); //construct a swriter since
WogrdDocument.writeAllText needs a writer

      //dump the document-text to our swriter to see if HDF works basically
      doc.writeAllText(swriter);
      content = swriter.toString();
    }
    catch (IOException e) {
      e.printStackTrace();
    }

I hope someone can help me

thx Amrûn

-- 
GMX ProMail (250 MB Mailbox, 50 FreeSMS, Virenschutz, 2,99 EUR/Monat...)
jetzt 3 Monate GRATIS + 3x DER SPIEGEL +++ http://www.gmx.net/derspiegel +++


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org