Class ByteBufferOutputStream
java.lang.Object
java.io.OutputStream
org.jgroups.util.BaseDataOutputStream
org.jgroups.util.ByteBufferOutputStream
- All Implemented Interfaces:
Closeable, DataOutput, Flushable, AutoCloseable
Class using
ByteBuffer and implementing DataOutput. The underlying ByteBuffer will be grown when
the capacity is too small.- Since:
- 3.5
- Author:
- Bela Ban
-
Field Summary
FieldsFields inherited from class BaseDataOutputStream
grow_exponentially, pos -
Constructor Summary
ConstructorsConstructorDescriptionByteBufferOutputStream(int capacity) ByteBufferOutputStream(int capacity, boolean grow_exponentially, boolean use_direct_memory) -
Method Summary
Modifier and TypeMethodDescriptionbuf()intcapacity()protected voidensureCapacity(int bytes) Grows the buffer; whether linearly or exponentially depends on grow_exponentiallyintlimit()intposition()position(int p) reset()toString()booleanvoidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(int b) 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 BaseDataOutputStream
checkBounds, growExponentially, growExponentiallyMethods inherited from class OutputStream
close, flush, nullOutputStream
-
Field Details
-
buf
-
use_direct_memory
protected boolean use_direct_memory
-
-
Constructor Details
-
ByteBufferOutputStream
-
ByteBufferOutputStream
public ByteBufferOutputStream() -
ByteBufferOutputStream
public ByteBufferOutputStream(int capacity) -
ByteBufferOutputStream
public ByteBufferOutputStream(int capacity, boolean grow_exponentially, boolean use_direct_memory)
-
-
Method Details
-
buf
-
reset
- Overrides:
resetin classBaseDataOutputStream
-
position
public int position()- Overrides:
positionin classBaseDataOutputStream
-
position
- Overrides:
positionin classBaseDataOutputStream
-
limit
public int limit() -
capacity
public int capacity() -
useDirectMemory
public boolean useDirectMemory() -
write
- Specified by:
writein interfaceDataOutput- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Overrides:
writein classOutputStream- Throws:
IOException
-
writeBoolean
- Specified by:
writeBooleanin interfaceDataOutput- Overrides:
writeBooleanin classBaseDataOutputStream- Throws:
IOException
-
writeByte
- Specified by:
writeBytein interfaceDataOutput- Overrides:
writeBytein classBaseDataOutputStream- Throws:
IOException
-
writeShort
- Specified by:
writeShortin interfaceDataOutput- Overrides:
writeShortin classBaseDataOutputStream- Throws:
IOException
-
writeChar
- Specified by:
writeCharin interfaceDataOutput- Overrides:
writeCharin classBaseDataOutputStream- Throws:
IOException
-
writeInt
- Specified by:
writeIntin interfaceDataOutput- Overrides:
writeIntin classBaseDataOutputStream- Throws:
IOException
-
writeLong
- Specified by:
writeLongin interfaceDataOutput- Overrides:
writeLongin classBaseDataOutputStream- Throws:
IOException
-
writeFloat
- Specified by:
writeFloatin interfaceDataOutput- Overrides:
writeFloatin classBaseDataOutputStream- Throws:
IOException
-
writeDouble
- Specified by:
writeDoublein interfaceDataOutput- Overrides:
writeDoublein classBaseDataOutputStream- Throws:
IOException
-
writeBytes
- Specified by:
writeBytesin interfaceDataOutput- Overrides:
writeBytesin classBaseDataOutputStream- Throws:
IOException
-
writeChars
- Specified by:
writeCharsin interfaceDataOutput- Overrides:
writeCharsin classBaseDataOutputStream- Throws:
IOException
-
writeUTF
- Specified by:
writeUTFin interfaceDataOutput- Overrides:
writeUTFin classBaseDataOutputStream- Throws:
IOException
-
toString
- Overrides:
toStringin classBaseDataOutputStream
-
ensureCapacity
protected void ensureCapacity(int bytes) Grows the buffer; whether linearly or exponentially depends on grow_exponentially- Specified by:
ensureCapacityin classBaseDataOutputStream
-