Package org.apache.activemq.util
Class DataByteArrayOutputStream
java.lang.Object
java.io.OutputStream
org.apache.activemq.util.DataByteArrayOutputStream
- All Implemented Interfaces:
Closeable,DataOutput,Flushable,AutoCloseable
Optimized ByteArrayOutputStream
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new byte array output stream.DataByteArrayOutputStream(int size) Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getData()voidposition(int offset) Set the current position for writingvoidreset()reset the output streamvoidrestart()start using a fresh byte arrayvoidrestart(int size) start using a fresh byte arrayintsize()Get a ByteSequence from the streamvoidwrite(byte[] b, int off, int len) Writeslenbytes from the specified byte array starting at offsetoffto this byte array output stream.voidwrite(int b) Writes the specified byte to this byte array output stream.voidwriteBoolean(boolean v) voidwriteByte(int v) voidwriteBytes(String s) voidwriteChar(int v) voidwriteChars(String s) voidwriteDouble(double v) voidwriteFloat(float v) voidwriteInt(int v) voidwriteLong(long v) voidwriteShort(int v) voidMethods inherited from class java.io.OutputStream
close, flush, nullOutputStream, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.io.DataOutput
write
-
Constructor Details
-
DataByteArrayOutputStream
public DataByteArrayOutputStream(int size) Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.- Parameters:
size- the initial size.- Throws:
IllegalArgumentException- if size is negative.
-
DataByteArrayOutputStream
public DataByteArrayOutputStream()Creates a new byte array output stream.
-
-
Method Details
-
restart
public void restart(int size) start using a fresh byte array- Parameters:
size-
-
restart
public void restart()start using a fresh byte array -
toByteSequence
Get a ByteSequence from the stream- Returns:
- the byte sequence
-
write
public void write(int b) Writes the specified byte to this byte array output stream.- Specified by:
writein interfaceDataOutput- Specified by:
writein classOutputStream- Parameters:
b- the byte to be written.
-
write
public void write(byte[] b, int off, int len) Writeslenbytes from the specified byte array starting at offsetoffto this byte array output stream.- Specified by:
writein interfaceDataOutput- Overrides:
writein classOutputStream- Parameters:
b- the data.off- the start offset in the data.len- the number of bytes to write.
-
getData
public byte[] getData()- Returns:
- the underlying byte[] buffer
-
reset
public void reset()reset the output stream -
position
public void position(int offset) Set the current position for writing- Parameters:
offset-
-
size
public int size() -
writeBoolean
public void writeBoolean(boolean v) - Specified by:
writeBooleanin interfaceDataOutput
-
writeByte
public void writeByte(int v) - Specified by:
writeBytein interfaceDataOutput
-
writeShort
public void writeShort(int v) - Specified by:
writeShortin interfaceDataOutput
-
writeChar
public void writeChar(int v) - Specified by:
writeCharin interfaceDataOutput
-
writeInt
public void writeInt(int v) - Specified by:
writeIntin interfaceDataOutput
-
writeLong
public void writeLong(long v) - Specified by:
writeLongin interfaceDataOutput
-
writeFloat
- Specified by:
writeFloatin interfaceDataOutput- Throws:
IOException
-
writeDouble
- Specified by:
writeDoublein interfaceDataOutput- Throws:
IOException
-
writeBytes
- Specified by:
writeBytesin interfaceDataOutput
-
writeChars
- Specified by:
writeCharsin interfaceDataOutput
-
writeUTF
- Specified by:
writeUTFin interfaceDataOutput- Throws:
IOException
-