Package org.jboss.marshalling
Class ByteBufferOutput
- java.lang.Object
-
- java.io.OutputStream
-
- org.jboss.marshalling.ByteBufferOutput
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
,ByteOutput
public class ByteBufferOutput extends java.io.OutputStream implements ByteOutput
AnOutputStream
implementingByteOutput
which writes to aByteBuffer
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteBuffer
buffer
-
Constructor Summary
Constructors Constructor Description ByteBufferOutput(java.nio.ByteBuffer buffer)
Create a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
private static java.io.IOException
readOnlyBuffer()
void
write(byte[] b)
Write all the bytes from the given array to the stream.void
write(byte[] b, int off, int len)
Write some of the bytes from the given array to the stream.void
write(int b)
Writes to the output stream the eight low-order bits of the argumentb
.private static java.io.EOFException
writePastEnd()
-
-
-
Method Detail
-
writePastEnd
private static java.io.EOFException writePastEnd()
-
readOnlyBuffer
private static java.io.IOException readOnlyBuffer()
-
write
public void write(int b) throws java.io.IOException
Writes to the output stream the eight low-order bits of the argumentb
. The 24 high-order bits ofb
are ignored.- Specified by:
write
in interfaceByteOutput
- Specified by:
write
in classjava.io.OutputStream
- Parameters:
b
- the byte to write- Throws:
java.io.IOException
- if an error occurs
-
write
public void write(byte[] b) throws java.io.IOException
Write all the bytes from the given array to the stream.- Specified by:
write
in interfaceByteOutput
- Overrides:
write
in classjava.io.OutputStream
- Parameters:
b
- the byte array- Throws:
java.io.IOException
- if an error occurs
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
Write some of the bytes from the given array to the stream.- Specified by:
write
in interfaceByteOutput
- Overrides:
write
in classjava.io.OutputStream
- Parameters:
b
- the byte arrayoff
- the index to start writing fromlen
- the number of bytes to write- Throws:
java.io.IOException
- if an error occurs
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
-