Class DocumentInputStream

java.lang.Object
java.io.InputStream
org.docx4j.org.apache.poi.poifs.filesystem.DocumentInputStream
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable, LittleEndianInput
Direct Known Subclasses:
NDocumentInputStream, ODocumentInputStream

public class DocumentInputStream
extends java.io.InputStream
implements LittleEndianInput
This class provides methods to read a DocumentEntry managed by a POIFSFileSystem or NPOIFSFileSystem instance. It creates the appropriate one, and delegates, allowing us to work transparently with the two.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected static int EOF
    returned by read operations if we're at end of document
    protected static int SIZE_INT  
    protected static int SIZE_LONG  
    protected static int SIZE_SHORT  
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected DocumentInputStream()
    For use by downstream implementations
      DocumentInputStream​(DocumentEntry document)
    Create an InputStream from the specified DocumentEntry
      DocumentInputStream​(NPOIFSDocument document)
    Create an InputStream from the specified Document
      DocumentInputStream​(OPOIFSDocument document)
    Create an InputStream from the specified Document
  • Method Summary

    Modifier and Type Method Description
    int available()  
    void close()  
    void mark​(int ignoredReadlimit)  
    boolean markSupported()
    Tests if this input stream supports the mark and reset methods.
    int read()  
    int read​(byte[] b)  
    int read​(byte[] b, int off, int len)  
    byte readByte()  
    double readDouble()  
    void readFully​(byte[] buf)  
    void readFully​(byte[] buf, int off, int len)  
    int readInt()  
    long readLong()  
    short readShort()  
    int readUByte()  
    long readUInt()  
    int readUShort()  
    void reset()
    Repositions this stream to the position at the time the mark() method was last called on this input stream.
    long skip​(long n)  

    Methods inherited from class java.io.InputStream

    nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • DocumentInputStream

      protected DocumentInputStream()
      For use by downstream implementations
    • DocumentInputStream

      public DocumentInputStream​(DocumentEntry document) throws java.io.IOException
      Create an InputStream from the specified DocumentEntry
      Parameters:
      document - the DocumentEntry to be read
      Throws:
      java.io.IOException - if the DocumentEntry cannot be opened (like, maybe it has been deleted?)
    • DocumentInputStream

      public DocumentInputStream​(OPOIFSDocument document)
      Create an InputStream from the specified Document
      Parameters:
      document - the Document to be read
    • DocumentInputStream

      public DocumentInputStream​(NPOIFSDocument document)
      Create an InputStream from the specified Document
      Parameters:
      document - the Document to be read
  • Method Details

    • available

      public int available()
      Specified by:
      available in interface LittleEndianInput
      Overrides:
      available in class java.io.InputStream
    • close

      public void close()
      Specified by:
      close in interface java.lang.AutoCloseable
      Specified by:
      close in interface java.io.Closeable
      Overrides:
      close in class java.io.InputStream
    • mark

      public void mark​(int ignoredReadlimit)
      Overrides:
      mark in class java.io.InputStream
    • markSupported

      public boolean markSupported()
      Tests if this input stream supports the mark and reset methods.
      Overrides:
      markSupported in class java.io.InputStream
      Returns:
      true always
    • read

      public int read() throws java.io.IOException
      Specified by:
      read in class java.io.InputStream
      Throws:
      java.io.IOException
    • read

      public int read​(byte[] b) throws java.io.IOException
      Overrides:
      read in class java.io.InputStream
      Throws:
      java.io.IOException
    • read

      public int read​(byte[] b, int off, int len) throws java.io.IOException
      Overrides:
      read in class java.io.InputStream
      Throws:
      java.io.IOException
    • reset

      public void reset()
      Repositions this stream to the position at the time the mark() method was last called on this input stream. If mark() has not been called this method repositions the stream to its beginning.
      Overrides:
      reset in class java.io.InputStream
    • skip

      public long skip​(long n) throws java.io.IOException
      Overrides:
      skip in class java.io.InputStream
      Throws:
      java.io.IOException
    • readByte

      public byte readByte()
      Specified by:
      readByte in interface LittleEndianInput
    • readDouble

      public double readDouble()
      Specified by:
      readDouble in interface LittleEndianInput
    • readShort

      public short readShort()
      Specified by:
      readShort in interface LittleEndianInput
    • readFully

      public void readFully​(byte[] buf)
      Specified by:
      readFully in interface LittleEndianInput
    • readFully

      public void readFully​(byte[] buf, int off, int len)
      Specified by:
      readFully in interface LittleEndianInput
    • readLong

      public long readLong()
      Specified by:
      readLong in interface LittleEndianInput
    • readInt

      public int readInt()
      Specified by:
      readInt in interface LittleEndianInput
    • readUShort

      public int readUShort()
      Specified by:
      readUShort in interface LittleEndianInput
    • readUByte

      public int readUByte()
      Specified by:
      readUByte in interface LittleEndianInput
    • readUInt

      public long readUInt()