Package com.tangosol.io
Class WrapperOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- com.tangosol.io.WrapperOutputStream
-
- All Implemented Interfaces:
com.oracle.coherence.common.io.OutputStreaming,OutputStreaming,Closeable,Flushable,AutoCloseable
- Direct Known Subclasses:
ExternalizableHelper.ShieldedOutputStream,PackedDataOutputStream
public class WrapperOutputStream extends OutputStream implements OutputStreaming
This is an OutputStream class that delegates to another OutputStream. Primarily, this is intended as a base class for building specific-purpose OutputStream wrappers.- Author:
- cp 2004.08.20
-
-
Field Summary
Fields Modifier and Type Field Description protected OutputStreamm_outThe underlying OutputStream object to use.
-
Constructor Summary
Constructors Constructor Description WrapperOutputStream()Construct an uninitialized WrapperOutputStream.WrapperOutputStream(OutputStream out)Construct a WrapperOutputStream that will output to the specified OutputStream object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this OutputStream and releases any associated system resources.protected OutputStreamensureOutputStream()Return the underlying OutputStream.voidflush()Flushes this OutputStream and forces any buffered output bytes to be written.OutputStreamgetOutputStream()Obtain the underlying OutputStream.voidsetOutputStream(OutputStream out)Specify the underlying OutputStream.voidwrite(byte[] ab)Writes all the bytes in the arrayab.voidwrite(byte[] ab, int of, int cb)Writescbbytes starting at offsetoffrom the arrayab.voidwrite(int b)Writes the eight low-order bits of the argumentb.-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Field Detail
-
m_out
protected OutputStream m_out
The underlying OutputStream object to use.
-
-
Constructor Detail
-
WrapperOutputStream
public WrapperOutputStream()
Construct an uninitialized WrapperOutputStream.
-
WrapperOutputStream
public WrapperOutputStream(OutputStream out)
Construct a WrapperOutputStream that will output to the specified OutputStream object.- Parameters:
out- an OutputStream object to write to
-
-
Method Detail
-
getOutputStream
public OutputStream getOutputStream()
Obtain the underlying OutputStream.- Returns:
- the underlying OutputStream
-
ensureOutputStream
protected OutputStream ensureOutputStream()
Return the underlying OutputStream.- Returns:
- the underlying OutputStream
- Throws:
IllegalStateException- if the underlying stream has not been specified.
-
setOutputStream
public void setOutputStream(OutputStream out)
Specify the underlying OutputStream. This method may only be called once with a non-null value.- Parameters:
out- the stream to be wrapped- Throws:
IllegalStateException- if the underlying stream has already been specified.
-
write
public void write(int b) throws IOExceptionWrites the eight low-order bits of the argumentb. The 24 high-order bits ofbare ignored.- Specified by:
writein interfacecom.oracle.coherence.common.io.OutputStreaming- Specified by:
writein classOutputStream- Parameters:
b- the byte to write (passed as an integer)- Throws:
IOException- if an I/O error occurs
-
write
public void write(byte[] ab) throws IOExceptionWrites all the bytes in the arrayab.- Specified by:
writein interfacecom.oracle.coherence.common.io.OutputStreaming- Overrides:
writein classOutputStream- Parameters:
ab- the byte array to write- Throws:
IOException- if an I/O error occursNullPointerException- ifabisnull
-
write
public void write(byte[] ab, int of, int cb) throws IOExceptionWritescbbytes starting at offsetoffrom the arrayab.- Specified by:
writein interfacecom.oracle.coherence.common.io.OutputStreaming- Overrides:
writein classOutputStream- Parameters:
ab- the byte array to write fromof- the offset intoabto start writing fromcb- the number of bytes fromabto write- Throws:
IOException- if an I/O error occursNullPointerException- ifabisnullIndexOutOfBoundsException- ifofis negative, orcbis negative, orof+cbis greater thanab.length
-
flush
public void flush() throws IOExceptionFlushes this OutputStream and forces any buffered output bytes to be written.- Specified by:
flushin interfaceFlushable- Specified by:
flushin interfacecom.oracle.coherence.common.io.OutputStreaming- Overrides:
flushin classOutputStream- Throws:
IOException- if an I/O error occurs
-
close
public void close() throws IOExceptionCloses this OutputStream and releases any associated system resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfacecom.oracle.coherence.common.io.OutputStreaming- Overrides:
closein classOutputStream- Throws:
IOException- if an I/O error occurs
-
-