|
||||||||||
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
org.apache.poi.poifs.filesystem.POIFSFileSystem
public class POIFSFileSystem
Transition class for the move from POIFSFileSystem
to
OPOIFSFileSystem
, and from NPOIFSFileSystem
to
POIFSFileSystem
. Currently, this is OPOIFS-powered
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.poi.poifs.filesystem.BlockStore |
---|
BlockStore.ChainLoopDetector |
Constructor Summary | |
---|---|
POIFSFileSystem()
Constructor, intended for writing |
|
POIFSFileSystem(java.io.File file)
Creates a POIFSFileSystem from a File. |
|
POIFSFileSystem(java.io.InputStream stream)
Create a POIFSFileSystem from an InputStream. |
Method Summary | |
---|---|
static java.io.InputStream |
createNonClosingInputStream(java.io.InputStream is)
Convenience method for clients that want to avoid the auto-close behaviour of the constructor. |
static boolean |
hasPOIFSHeader(byte[] header8Bytes)
Checks if the supplied first 8 bytes of a stream / file has a POIFS (OLE2) header. |
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 |
Methods inherited from class org.apache.poi.poifs.filesystem.NPOIFSFileSystem |
---|
close, createBlockIfNeeded, createDirectory, createDocument, createDocument, createDocumentInputStream, getBATBlockAndIndex, getBigBlockSize, getBigBlockSizeDetails, getBlockAt, getBlockStoreBlockSize, getChainLoopDetector, getFreeBlock, getHeaderBlock, getMiniStore, getNextBlock, getPropertyTable, getRoot, getShortDescription, getViewableArray, getViewableIterator, preferArray, setNextBlock, size, writeFilesystem, writeFilesystem |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.poi.poifs.dev.POIFSViewable |
---|
getShortDescription, getViewableArray, getViewableIterator, preferArray |
Constructor Detail |
---|
public POIFSFileSystem()
public POIFSFileSystem(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 datapublic POIFSFileSystem(java.io.File file) throws java.io.IOException
Creates a POIFSFileSystem from a File. This uses less memory than creating from an InputStream. The File will be opened read-only
Note that with this constructor, you will need to call NPOIFSFileSystem.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 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 static boolean hasPOIFSHeader(byte[] header8Bytes)
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |