Top Description Fields Constructors Methods
org.apache.poi.poifs.filesystem

public final Class DocumentOutputStream

extends OutputStream
Class Inheritance
Imports
java.io.IOException, .OutputStream, org.apache.commons.io.input.UnsynchronizedByteArrayInputStream, org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream, org.apache.poi.poifs.common.POIFSConstants, org.apache.poi.poifs.property.DocumentProperty

This class provides methods to write a DocumentEntry managed by a POIFSFileSystem instance.

Field Summary

Modifier and TypeField and Description
private UnsynchronizedByteArrayOutputStream
_buffer

our buffer, when null we're into normal blocks

private boolean
_closed

have we been closed?

private final POIFSDocument
_document

the actual Document

private int
_document_size

the Document's size, i.e. the size of the big block data - mini block data is cached and not counted

private final long
_limit

a write limit or -1 if unlimited

private final DocumentProperty
_property

and its Property

private POIFSStream
_stream

our main block stream, when we're into normal blocks

private OutputStream

Constructor Summary

AccessConstructor and Description
public
DocumentOutputStream(DocumentEntry
the DocumentEntry to be written
document
)

Create an OutputStream from the specified DocumentEntry.

public
DocumentOutputStream(DirectoryEntry
Where to create the Entry
parent
,
String
Name of the new entry
name
)

Create an OutputStream to create the specified new Entry

pack-priv
DocumentOutputStream(DocumentEntry
the DocumentEntry to which the data is actually written
document
,
long
the maximum number of bytes that can be written
limit
)

Create a DocumentOutputStream

pack-priv
DocumentOutputStream(POIFSDocument document, long limit)

Method Summary

Modifier and TypeMethod and Description
private void
public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with this stream.

private static DocumentEntry
private static POIFSDocument
public long

Returns:

the amount of written bytes
size
()

public void
write(int
the byte.
b
)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.

public void
write(byte[]
the data.
b
,
int
the start offset in the data.
off
,
int
the number of bytes to write.
len
)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Inherited from java.io.OutputStream:
flushnullOutputStreamwrite

Field Detail

_bufferback to summary
private UnsynchronizedByteArrayOutputStream _buffer

our buffer, when null we're into normal blocks

_closedback to summary
private boolean _closed

have we been closed?

_documentback to summary
private final POIFSDocument _document

the actual Document

_document_sizeback to summary
private int _document_size

the Document's size, i.e. the size of the big block data - mini block data is cached and not counted

_limitback to summary
private final long _limit

a write limit or -1 if unlimited

_propertyback to summary
private final DocumentProperty _property

and its Property

_streamback to summary
private POIFSStream _stream

our main block stream, when we're into normal blocks

_stream_outputback to summary
private OutputStream _stream_output

Constructor Detail

DocumentOutputStreamback to summary
public DocumentOutputStream(DocumentEntry document) throws IOException

Create an OutputStream from the specified DocumentEntry. The specified entry will be emptied.

Parameters
document:DocumentEntry

the DocumentEntry to be written

DocumentOutputStreamback to summary
public DocumentOutputStream(DirectoryEntry parent, String name) throws IOException

Create an OutputStream to create the specified new Entry

Parameters
parent:DirectoryEntry

Where to create the Entry

name:String

Name of the new entry

DocumentOutputStreamback to summary
pack-priv DocumentOutputStream(DocumentEntry document, long limit) throws IOException

Create a DocumentOutputStream

Parameters
document:DocumentEntry

the DocumentEntry to which the data is actually written

limit:long

the maximum number of bytes that can be written

DocumentOutputStreamback to summary
pack-priv DocumentOutputStream(POIFSDocument document, long limit) throws IOException

Method Detail

checkBufferSizeback to summary
private void checkBufferSize() throws IOException
closeback to summary
public void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.OutputStream.close.

Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
createDocumentback to summary
private static DocumentEntry createDocument(DirectoryEntry parent, String name) throws IOException
getDocumentback to summary
private static POIFSDocument getDocument(DocumentEntry document) throws IOException
sizeback to summary
public long size()
Returns:long

the amount of written bytes

writeback to summary
public void write(int b) throws IOException

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters
b:int

the byte.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
writeback to summary
public void write(byte[] b, int off, int len) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Parameters
b:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.