|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.poi.poifs.filesystem.BlockStore
org.apache.poi.poifs.filesystem.NPOIFSFileSystem
public class NPOIFSFileSystem
This is the main class of the POIFS system; it manages the entire life cycle of the filesystem. This is the new NIO version
Constructor Summary | |
---|---|
NPOIFSFileSystem()
Constructor, intended for writing |
|
NPOIFSFileSystem(java.io.File file)
Creates a POIFSFileSystem from a File. |
|
NPOIFSFileSystem(java.io.File file,
boolean readOnly)
Creates a POIFSFileSystem from a File. |
|
NPOIFSFileSystem(java.nio.channels.FileChannel channel)
Creates a POIFSFileSystem from an open FileChannel. |
|
NPOIFSFileSystem(java.io.InputStream stream)
Create a POIFSFileSystem from an InputStream. |
Method Summary | |
---|---|
void |
close()
Closes the FileSystem, freeing any underlying files, streams and buffers. |
DirectoryEntry |
createDirectory(java.lang.String name)
create a new DirectoryEntry in the root directory |
DocumentEntry |
createDocument(java.io.InputStream stream,
java.lang.String name)
Create a new document to be added to the root directory |
DocumentEntry |
createDocument(java.lang.String name,
int size,
POIFSWriterListener writer)
create a new DocumentEntry in the root entry; the data will be provided later |
DocumentInputStream |
createDocumentInputStream(java.lang.String documentName)
open a document in the root entry's list of entries |
static java.io.InputStream |
createNonClosingInputStream(java.io.InputStream is)
Convenience method for clients that want to avoid the auto-close behaviour of the constructor. |
int |
getBigBlockSize()
|
POIFSBigBlockSize |
getBigBlockSizeDetails()
|
NPOIFSMiniStore |
getMiniStore()
Returns the MiniStore, which performs a similar low level function to this, except for the small blocks. |
DirectoryNode |
getRoot()
Get the root entry |
java.lang.String |
getShortDescription()
Provides a short description of the object, to be used when a POIFSViewable object has not provided its contents. |
java.lang.Object[] |
getViewableArray()
Get an array of objects, some of which may implement POIFSViewable |
java.util.Iterator |
getViewableIterator()
Get an Iterator of objects, some of which may implement POIFSViewable |
static boolean |
hasPOIFSHeader(java.io.InputStream inp)
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. |
static void |
main(java.lang.String[] args)
read in a file and write it back out again |
boolean |
preferArray()
Give viewers a hint as to whether to call getViewableArray or getViewableIterator |
void |
writeFilesystem()
Write the filesystem out to the open file. |
void |
writeFilesystem(java.io.OutputStream stream)
Write the filesystem out |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NPOIFSFileSystem()
public NPOIFSFileSystem(java.io.File file) throws java.io.IOException
close()
when you're done to have the underlying file closed, as the file is kept
open during normal operation to read the data out.
file
- the File from which to read the data
java.io.IOException
- on errors reading, or on invalid datapublic NPOIFSFileSystem(java.io.File file, boolean readOnly) throws java.io.IOException
close()
when you're done to have the underlying file closed, as the file is kept
open during normal operation to read the data out.
file
- the File from which to read the data
java.io.IOException
- on errors reading, or on invalid datapublic NPOIFSFileSystem(java.nio.channels.FileChannel channel) throws java.io.IOException
close()
when you're done to have the underlying Channel closed, as the channel is
kept open during normal operation to read the data out.
channel
- the FileChannel from which to read the data
java.io.IOException
- on errors reading, or on invalid datapublic NPOIFSFileSystem(java.io.InputStream stream) throws java.io.IOException
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);
stream
- the InputStream from which to read the data
java.io.IOException
- on errors reading, or on invalid dataMethod Detail |
---|
public static java.io.InputStream createNonClosingInputStream(java.io.InputStream is)
public static boolean hasPOIFSHeader(java.io.InputStream inp) throws java.io.IOException
inp
- An InputStream which supports either mark/reset, or is a PushbackInputStream
java.io.IOException
public NPOIFSMiniStore getMiniStore()
public DocumentEntry createDocument(java.io.InputStream stream, java.lang.String name) throws java.io.IOException
stream
- the InputStream from which the document's data
will be obtainedname
- the name of the new POIFSDocument
java.io.IOException
- on error creating the new POIFSDocumentpublic DocumentEntry createDocument(java.lang.String name, int size, POIFSWriterListener writer) throws java.io.IOException
name
- the name of the new DocumentEntrysize
- the size of the new DocumentEntrywriter
- the writer of the new DocumentEntry
java.io.IOException
public DirectoryEntry createDirectory(java.lang.String name) throws java.io.IOException
name
- the name of the new DirectoryEntry
java.io.IOException
- on name duplicationpublic void writeFilesystem() throws java.io.IOException
IllegalArgumentException
if opened from an InputStream
.
java.io.IOException
- thrown on errors writing to the streampublic void writeFilesystem(java.io.OutputStream stream) throws java.io.IOException
stream
- the OutputStream to which the filesystem will be
written
java.io.IOException
- thrown on errors writing to the streampublic void close() throws java.io.IOException
close
in interface Closeable
java.io.IOException
public static void main(java.lang.String[] args) throws java.io.IOException
args
- names of the files; arg[ 0 ] is the input file,
arg[ 1 ] is the output file
java.io.IOException
public DirectoryNode getRoot()
public DocumentInputStream createDocumentInputStream(java.lang.String documentName) throws java.io.IOException
documentName
- the name of the document to be opened
java.io.IOException
- if the document does not exist or the
name is that of a DirectoryEntrypublic java.lang.Object[] getViewableArray()
getViewableArray
in interface POIFSViewable
public java.util.Iterator getViewableIterator()
getViewableIterator
in interface POIFSViewable
public boolean preferArray()
preferArray
in interface POIFSViewable
public java.lang.String getShortDescription()
getShortDescription
in interface POIFSViewable
public int getBigBlockSize()
public POIFSBigBlockSize getBigBlockSizeDetails()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |