Class POIFSReader
java.lang.Object
org.docx4j.org.apache.poi.poifs.eventfilesystem.POIFSReader
public class POIFSReader
extends java.lang.Object
An event-driven reader for POIFS file systems. Users of this class
first create an instance of it, then use the registerListener
methods to register POIFSReaderListener instances for specific
documents. Once all the listeners have been registered, the read()
method is called, which results in the listeners being notified as
their documents are read.
- Author:
- Marc Johnson (mjohnson at apache dot org)
-
Constructor Summary
Constructors Constructor Description POIFSReader()Create a POIFSReader -
Method Summary
Modifier and Type Method Description static voidmain(java.lang.String[] args)read in filesvoidread(java.io.InputStream stream)Read from an InputStream and process the documents we getvoidregisterListener(POIFSReaderListener listener)Register a POIFSReaderListener for all documentsvoidregisterListener(POIFSReaderListener listener, java.lang.String name)Register a POIFSReaderListener for a document in the root directoryvoidregisterListener(POIFSReaderListener listener, POIFSDocumentPath path, java.lang.String name)Register a POIFSReaderListener for a document in the specified directory
-
Constructor Details
-
POIFSReader
public POIFSReader()Create a POIFSReader
-
-
Method Details
-
read
public void read(java.io.InputStream stream) throws java.io.IOExceptionRead from an InputStream and process the documents we get- Parameters:
stream- the InputStream from which to read the data- Throws:
java.io.IOException- on errors reading, or on invalid data
-
registerListener
Register a POIFSReaderListener for all documents- Parameters:
listener- the listener to be registered- Throws:
java.lang.NullPointerException- if listener is nulljava.lang.IllegalStateException- if read() has already been called
-
registerListener
Register a POIFSReaderListener for a document in the root directory- Parameters:
listener- the listener to be registeredname- the document name- Throws:
java.lang.NullPointerException- if listener is null or name is null or emptyjava.lang.IllegalStateException- if read() has already been called
-
registerListener
public void registerListener(POIFSReaderListener listener, POIFSDocumentPath path, java.lang.String name)Register a POIFSReaderListener for a document in the specified directory- Parameters:
listener- the listener to be registeredpath- the document path; if null, the root directory is assumedname- the document name- Throws:
java.lang.NullPointerException- if listener is null or name is null or emptyjava.lang.IllegalStateException- if read() has already been called
-
main
public static void main(java.lang.String[] args) throws java.io.IOExceptionread in files- Parameters:
args- names of the files- Throws:
java.io.IOException
-