public class ByteArrayDataOutputStream
extends java.lang.Object
implements java.io.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() |
java.nio.ByteBuffer |
getByteBuffer() |
boolean |
growExponentially() |
ByteArrayDataOutputStream |
growExponentially(boolean b) |
int |
position() |
ByteArrayDataOutputStream |
position(int pos) |
java.lang.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(java.lang.String s) |
void |
writeChar(int v) |
void |
writeChars(java.lang.String s) |
void |
writeDouble(double v) |
void |
writeFloat(float v) |
void |
writeInt(int v) |
void |
writeLong(long v) |
void |
writeShort(int v) |
void |
writeUTF(java.lang.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 java.nio.ByteBuffer getByteBuffer()
public boolean growExponentially()
public ByteArrayDataOutputStream growExponentially(boolean b)
public void write(int b)
write in interface java.io.DataOutputpublic void write(byte[] b)
write in interface java.io.DataOutputpublic void write(byte[] b,
int off,
int len)
write in interface java.io.DataOutputpublic void writeBoolean(boolean v)
writeBoolean in interface java.io.DataOutputpublic void writeByte(int v)
writeByte in interface java.io.DataOutputpublic void writeShort(int v)
writeShort in interface java.io.DataOutputpublic void writeChar(int v)
writeChar in interface java.io.DataOutputpublic void writeInt(int v)
writeInt in interface java.io.DataOutputpublic void writeLong(long v)
writeLong in interface java.io.DataOutputpublic void writeFloat(float v)
writeFloat in interface java.io.DataOutputpublic void writeDouble(double v)
writeDouble in interface java.io.DataOutputpublic void writeBytes(java.lang.String s)
writeBytes in interface java.io.DataOutputpublic void writeChars(java.lang.String s)
writeChars in interface java.io.DataOutputpublic void writeUTF(java.lang.String str)
writeUTF in interface java.io.DataOutputpublic java.lang.String toString()
toString in class java.lang.Objectprotected int checkBounds(int pos)
protected void ensureCapacity(int bytes)
Copyright © 1998-2020 Red Hat. All Rights Reserved.