Package org.apache.poi
Class POIDocument
java.lang.Object
org.apache.poi.POIDocument
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
HPSFPropertiesOnlyDocument,HSLFSlideShow,HSLFSlideShowImpl,HSSFWorkbook,HWPFDocumentCore,POIReadOnlyDocument
This holds the common functionality for all POI
Document classes.
Currently, this relates to Document Information Properties
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the underlyingPOIFSFileSystemfrom which the document was read, if any.voidWill create whichever of SummaryInformation and DocumentSummaryInformation (HPSF) properties are not already part of your document.Fetch the Document Summary Information of the documentFetch the Summary Information of the documentvoidFind, and create objects for, the standard Document Information Properties (HPSF).abstract voidwrite()Writes the document out to the currently openFile, via the writeablePOIFSFileSystemit was opened from.abstract voidWrites the document out to the specified newFile.abstract voidwrite(OutputStream out) Writes the document out to the specified output stream.voidwriteProperties(POIFSFileSystem outFS) Writes out the standard Document Information Properties (HPSF)
-
Method Details
-
getDocumentSummaryInformation
Fetch the Document Summary Information of the document- Returns:
- The Document Summary Information or null if it could not be read for this document.
-
getSummaryInformation
Fetch the Summary Information of the document- Returns:
- The Summary information for the document or null if it could not be read for this document.
-
createInformationProperties
public void createInformationProperties()Will create whichever of SummaryInformation and DocumentSummaryInformation (HPSF) properties are not already part of your document. This is normally useful when creating a new document from scratch. If the information properties are already there, then nothing will happen. -
readProperties
Find, and create objects for, the standard Document Information Properties (HPSF). If a given property set is missing or corrupt, it will remain null; -
writeProperties
Writes out the standard Document Information Properties (HPSF)- Parameters:
outFS- the POIFSFileSystem to write the properties into- Throws:
IOException- if an error when writing to thePOIFSFileSystemoccurs
-
write
Writes the document out to the currently openFile, via the writeablePOIFSFileSystemit was opened from.This will fail (with an
IllegalStateExceptionif the document was opened read-only, opened from anInputStreaminstead of a File, or if this is not the root document. For those cases, you must usewrite(OutputStream)orwrite(File)to write to a brand new document.- Throws:
IOException- thrown on errors writing to the fileIllegalStateException- if this isn't from a writable File- Since:
- POI 3.15 beta 3
-
write
Writes the document out to the specified newFile. If the file exists, it will be replaced, otherwise a new one will be created- Parameters:
newFile- The new File to write to.- Throws:
IOException- thrown on errors writing to the file- Since:
- POI 3.15 beta 3
-
write
Writes the document out to the specified output stream. The stream is not closed as part of this operation. Note - if the Document was opened from aFilerather than anInputStream, you must write out usingwrite()or to a different File. Overwriting the currently open file via an OutputStream isn't possible. Ifstreamis aFileOutputStreamon a networked drive or has a high cost/latency associated with each written byte, consider wrapping the OutputStream in aBufferedOutputStreamto improve write performance, or usewrite()/write(File)if possible.- Parameters:
out- The stream to write to.- Throws:
IOException- thrown on errors writing to the stream
-
close
Closes the underlyingPOIFSFileSystemfrom which the document was read, if any. Has no effect on documents opened from an InputStream, or newly created ones.Once
close()has been called, no further operations should be called on the document.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getDirectory
-
getEncryptionInfo
- Returns:
- the encryption info if the document is encrypted, otherwise
null - Throws:
IOException- If retrieving the encryption information fails
-