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 ChannelImageOutputStream
The underlying data output stream. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new output stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Releases any system resources associated with the output stream.void
flush()
Forces any buffered output bytes to be written out.long
Returns the current byte position of the stream.void
mark()
Marks the current position in this output stream.void
reset()
Resets this stream to the position at the time themark
method was last called.void
reset
(long mark) Moves to the given position in the stream and discards all marks at or after that position.void
write
(byte[] b) Writes the specified bytes to the output stream.void
write
(byte[] b, int off, int len) Writes the specified sub-array to the output stream.void
write
(int b) Writes the specified byte to the output stream.Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
output
The underlying data output stream. In principle, public access to this field breaks encapsulation. But sinceOutputStreamAdapter
does 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:
write
in 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:
write
in 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:
write
in 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 themark
method was last called.- Specified by:
reset
in 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:
reset
in 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:
getStreamPosition
in 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:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
- if an I/O error occurs.
-
close
Releases any system resources associated with the output stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
- if an I/O error occurs.
-