Save This Page
Home » poi-src-3.2-FINAL-20081019 » org.apache.poi.poifs » filesystem » [javadoc | source]
org.apache.poi.poifs.filesystem
public class: POIFSFileSystem [javadoc | source]
java.lang.Object
   org.apache.poi.poifs.filesystem.POIFSFileSystem

All Implemented Interfaces:
    POIFSViewable

This is the main class of the POIFS system; it manages the entire life cycle of the filesystem.
Constructor:
 public POIFSFileSystem() 
 public POIFSFileSystem(InputStream stream) throws IOException 
    Create a POIFSFileSystem from an InputStream. Normally the stream is read until EOF. The stream is always closed.

    Some streams are usable after reaching EOF (typically those that return true for markSupported()). In the unlikely case that the caller has such a stream and needs to use it after this constructor completes, a work around is to wrap the stream in order to trap the close() call. A convenience method ( createNonClosingInputStream()) has been provided for this purpose:

    InputStream wrappedStream = POIFSFileSystem.createNonClosingInputStream(is);
    HSSFWorkbook wb = new HSSFWorkbook(wrappedStream);
    is.reset();
    doSomethingElse(is);
    
    Note also the special case of ByteArrayInputStream for which the close() method does nothing.
    ByteArrayInputStream bais = ...
    HSSFWorkbook wb = new HSSFWorkbook(bais); // calls bais.close() !
    bais.reset(); // no problem
    doSomethingElse(bais);
    
    Parameters:
    stream - the InputStream from which to read the data
    Throws:
    IOException - on errors reading, or on invalid data
    exception: IOException - on errors reading, or on invalid data
Method from org.apache.poi.poifs.filesystem.POIFSFileSystem Summary:
addDirectory,   addDocument,   createDirectory,   createDocument,   createDocument,   createDocumentInputStream,   createNonClosingInputStream,   getBigBlockSize,   getRoot,   getShortDescription,   getViewableArray,   getViewableIterator,   hasPOIFSHeader,   main,   preferArray,   remove,   writeFilesystem
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.poi.poifs.filesystem.POIFSFileSystem Detail:
  void addDirectory(DirectoryProperty directory) 
    add a new DirectoryProperty
  void addDocument(POIFSDocument document) 
    add a new POIFSDocument
 public DirectoryEntry createDirectory(String name) throws IOException 
    create a new DirectoryEntry in the root directory
 public DocumentEntry createDocument(InputStream stream,
    String name) throws IOException 
    Create a new document to be added to the root directory
 public DocumentEntry createDocument(String name,
    int size,
    POIFSWriterListener writer) throws IOException 
    create a new DocumentEntry in the root entry; the data will be provided later
 public DocumentInputStream createDocumentInputStream(String documentName) throws IOException 
    open a document in the root entry's list of entries
 public static InputStream createNonClosingInputStream(InputStream is) 
    Convenience method for clients that want to avoid the auto-close behaviour of the constructor.
 public int getBigBlockSize() 
 public DirectoryNode getRoot() 
    get the root entry
 public String getShortDescription() 
    Provides a short description of the object, to be used when a POIFSViewable object has not provided its contents.
 public Object[] getViewableArray() 
    Get an array of objects, some of which may implement POIFSViewable
 public Iterator getViewableIterator() 
    Get an Iterator of objects, some of which may implement POIFSViewable
 public static boolean hasPOIFSHeader(InputStream inp) throws IOException 
    Checks that the supplied InputStream (which MUST support mark and reset, or be a PushbackInputStream) has a POIFS (OLE2) header at the start of it. If your InputStream does not support mark / reset, then wrap it in a PushBackInputStream, then be sure to always use that, and not the original!
 public static  void main(String[] args) throws IOException 
    read in a file and write it back out again
 public boolean preferArray() 
    Give viewers a hint as to whether to call getViewableArray or getViewableIterator
  void remove(EntryNode entry) 
    remove an entry
 public  void writeFilesystem(OutputStream stream) throws IOException 
    Write the filesystem out