Package com.tangosol.io.nio
Class ByteBufferOutputStream
java.lang.Object
java.io.OutputStream
com.tangosol.io.nio.ByteBufferOutputStream
- All Implemented Interfaces:
- com.oracle.coherence.common.io.OutputStreaming,- OutputStreaming,- Closeable,- Flushable,- AutoCloseable
An OutputStream implementation on top of a Java NIO ByteBuffer.
- Since:
- Coherence 2.2
- Author:
- cp 2002.09.06
- 
Constructor SummaryConstructorsConstructorDescriptionByteBufferOutputStream(ByteBuffer buffer) Construct a ByteBufferOutputStream on a ByteBuffer object.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Close the stream, flushing any accumulated bytes.voidflush()Flush any accumulated bytes.Obtain the ByteBuffer that this OutputStream is based on.protected static StringProvide a "suffix" containing the exception message (if any).protected NullPointerExceptionCheck if an NPE is caused by the stream being closed.voidwrite(byte[] abSrc, int ofSrc, int cbSrc) Writeslenbytes from the specified byte array starting at offsetoffto this output stream.voidwrite(int b) Writes the specified byte to this output stream.Methods inherited from class java.io.OutputStreamnullOutputStream, writeMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.oracle.coherence.common.io.OutputStreamingwrite
- 
Constructor Details- 
ByteBufferOutputStreamConstruct a ByteBufferOutputStream on a ByteBuffer object.- Parameters:
- buffer- the ByteBuffer to write the data to
 
 
- 
- 
Method Details- 
getByteBufferObtain the ByteBuffer that this OutputStream is based on.- Returns:
- the underlying ByteBuffer
 
- 
writeWrites the specified byte to this output stream.- Specified by:
- writein interface- com.oracle.coherence.common.io.OutputStreaming
- Specified by:
- writein class- OutputStream
- Parameters:
- b- the- byte
- Throws:
- IOException- if an I/O error occurs
 
- 
writeWriteslenbytes from the specified byte array starting at offsetoffto this output stream.If bisnull, aNullPointerExceptionis thrown.If offis negative, orlenis negative, oroff+lenis greater than the length of the arrayb, then an IndexOutOfBoundsException is thrown.- Specified by:
- writein interface- com.oracle.coherence.common.io.OutputStreaming
- Overrides:
- writein class- OutputStream
- Parameters:
- abSrc- the data
- ofSrc- the start offset in the data
- cbSrc- the number of bytes to write
- Throws:
- IOException- if an I/O error occurs
 
- 
flushFlush any accumulated bytes.- Specified by:
- flushin interface- Flushable
- Specified by:
- flushin interface- com.oracle.coherence.common.io.OutputStreaming
- Overrides:
- flushin class- OutputStream
- Throws:
- IOException- if an I/O error occurs
 
- 
closeClose the stream, flushing any accumulated bytes. The underlying buffer is not closed.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- com.oracle.coherence.common.io.OutputStreaming
- Overrides:
- closein class- OutputStream
- Throws:
- IOException- if an I/O error occurs
 
- 
includeMessageProvide a "suffix" containing the exception message (if any).- Parameters:
- e- an exception (any Throwable object)
- Returns:
- either an empty string (no message) or a suitable suffix for an error message
 
- 
potentialStreamClosedExceptionprotected NullPointerException potentialStreamClosedException(NullPointerException e) throws IOException Check if an NPE is caused by the stream being closed. Either throws an IO exception if the stream is closed or throws the original NPE.- Parameters:
- e- an NPE
- Returns:
- this method never returns normally but is designed so that the developer can write "throw potentialStreamClosedException(e)" so that the compiler knows that an exception is thrown at that point in the code
- Throws:
- IOException- if the stream is closed
 
 
-