Class OutputStreamAdapter
java.lang.Object
java.io.OutputStream
org.apache.sis.internal.storage.io.OutputStreamAdapter
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,Markable
Wraps a
ChannelDataOutput as a standard OutputStream.- Since:
- 0.8
- Version:
- 1.2
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final ChannelImageOutputStreamThe underlying data output stream. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new output stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Releases any system resources associated with the output stream.voidflush()Forces any buffered output bytes to be written out.longReturns the current byte position of the stream.voidmark()Marks the current position in this output stream.voidreset()Resets this stream to the position at the time themarkmethod was last called.voidreset(long mark) Moves to the given position in the stream and discards all marks at or after that position.voidwrite(byte[] b) Writes the specified bytes to the output stream.voidwrite(byte[] b, int off, int len) Writes the specified sub-array to the output stream.voidwrite(int b) Writes the specified byte to the output stream.
-
Field Details
-
output
The underlying data output stream. In principle, public access to this field breaks encapsulation. But sinceOutputStreamAdapterdoes not hold any state and just forwards every method calls to thatChannelDataOutput, using on object or the other does not make a difference.
-
-
Constructor Details
-
OutputStreamAdapter
OutputStreamAdapter(ChannelImageOutputStream output) Constructs a new output stream.- Parameters:
output- the stream to wrap.
-
-
Method Details
-
write
Writes the specified byte to the output stream.- Specified by:
writein classOutputStream- Parameters:
b- the byte to write.- Throws:
IOException- if an I/O error occurs.
-
write
Writes the specified bytes to the output stream.- Overrides:
writein classOutputStream- Parameters:
b- the bytes to write.- Throws:
IOException- if an I/O error occurs.
-
write
Writes the specified sub-array to the output stream.- Overrides:
writein classOutputStream- Parameters:
b- the bytes to write.off- the start offset in the data.len- the number of bytes to write.- Throws:
IOException- if an I/O error occurs.
-
mark
public void mark()Marks the current position in this output stream. -
reset
Resets this stream to the position at the time themarkmethod was last called.- Specified by:
resetin interfaceMarkable- Throws:
IOException- if this stream cannot move to the last mark position.- See Also:
-
reset
Moves to the given position in the stream and discards all marks at or after that position.- Specified by:
resetin interfaceMarkable- Parameters:
mark- position where to seek.- Throws:
IOException- if this stream cannot move to the specified mark position.
-
getStreamPosition
Returns the current byte position of the stream.- Specified by:
getStreamPositionin interfaceMarkable- Returns:
- the position of the stream.
- Throws:
IOException- if the position cannot be obtained.
-
flush
Forces any buffered output bytes to be written out.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException- if an I/O error occurs.
-
close
Releases any system resources associated with the output stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- if an I/O error occurs.
-