public class ByteArrayDataOutputStream extends Object implements DataOutput
DataOutput over a byte[] buffer. The byte[] buffer expands when needed; however, it
doesn't double but only expands minimally, to accommodate the additional data.
It is therefore recommended to always size the buffer to the actual number of bytes needed.
This class is not thread safe.| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buf |
protected boolean |
grow_exponentially |
protected int |
pos |
| Constructor and Description |
|---|
ByteArrayDataOutputStream() |
ByteArrayDataOutputStream(int capacity) |
ByteArrayDataOutputStream(int capacity,
boolean grow_exponentially) |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
buffer() |
protected int |
checkBounds(int pos) |
protected void |
ensureCapacity(int bytes)
Grows the buffer; whether it grow linearly or exponentially depends on grow_exponentially
|
Buffer |
getBuffer() |
ByteBuffer |
getByteBuffer() |
boolean |
growExponentially() |
ByteArrayDataOutputStream |
growExponentially(boolean b) |
int |
position() |
ByteArrayDataOutputStream |
position(int pos) |
String |
toString() |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
void |
writeBoolean(boolean v) |
void |
writeByte(int v) |
void |
writeBytes(String s) |
void |
writeChar(int v) |
void |
writeChars(String s) |
void |
writeDouble(double v) |
void |
writeFloat(float v) |
void |
writeInt(int v) |
void |
writeLong(long v) |
void |
writeShort(int v) |
void |
writeUTF(String str) |
protected byte[] buf
protected int pos
protected boolean grow_exponentially
public ByteArrayDataOutputStream()
public ByteArrayDataOutputStream(int capacity)
public ByteArrayDataOutputStream(int capacity,
boolean grow_exponentially)
public ByteArrayDataOutputStream position(int pos)
public int position()
public byte[] buffer()
public Buffer getBuffer()
public ByteBuffer getByteBuffer()
public boolean growExponentially()
public ByteArrayDataOutputStream growExponentially(boolean b)
public void write(int b)
write in interface DataOutputpublic void write(byte[] b)
write in interface DataOutputpublic void write(byte[] b,
int off,
int len)
write in interface DataOutputpublic void writeBoolean(boolean v)
writeBoolean in interface DataOutputpublic void writeByte(int v)
writeByte in interface DataOutputpublic void writeShort(int v)
writeShort in interface DataOutputpublic void writeChar(int v)
writeChar in interface DataOutputpublic void writeInt(int v)
writeInt in interface DataOutputpublic void writeLong(long v)
writeLong in interface DataOutputpublic void writeFloat(float v)
writeFloat in interface DataOutputpublic void writeDouble(double v)
writeDouble in interface DataOutputpublic void writeBytes(String s)
writeBytes in interface DataOutputpublic void writeChars(String s)
writeChars in interface DataOutputpublic void writeUTF(String str)
writeUTF in interface DataOutputprotected int checkBounds(int pos)
protected void ensureCapacity(int bytes)
Copyright © 2025 JBoss, a division of Red Hat. All rights reserved.