public class DataBuffer extends Object implements DataInput, DataOutput
DataInput and DataOutput interfaces.| Constructor and Description |
|---|
DataBuffer()
Creates a new instance with empty buffer.
|
DataBuffer(int initialCapacity)
Creates a new instance with empty buffer.
|
DataBuffer(int initialCapacity,
double expansionFactor)
Creates a new instance with empty buffer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
ensureCapacity(int newSize)
Ensures capacity of this buffer.
|
byte[] |
getData()
Returns the data bytes.
|
int |
getReadLimit()
Returns the reading limit position in this buffer.
|
int |
getReadPosition()
Returns the reading position in this buffer.
|
int |
getReadRemaining()
Returns the data length in this buffer.
|
int |
getWritePosition()
Returns the next write position in this buffer.
|
int |
read()
Reads a byte value.
|
boolean |
readBoolean() |
byte |
readByte() |
char |
readChar() |
double |
readDouble() |
float |
readFloat() |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
int |
readInt() |
String |
readLine() |
long |
readLong() |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
String |
readUTF() |
void |
reset(byte[] bytes,
int offset,
int length)
Resets data in this buffer.
|
void |
reset(int offset,
int length)
Resets cursors in this buffer.
|
int |
skipBytes(int n) |
String |
toString() |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(DataInput in,
int len)
Writes data from
DataInput. |
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 s) |
public DataBuffer()
public DataBuffer(int initialCapacity)
initialCapacity - the initial buffer capacity in bytespublic DataBuffer(int initialCapacity,
double expansionFactor)
initialCapacity - the initial buffer capacity in bytesexpansionFactor - the buffer expansion factorpublic void reset(byte[] bytes,
int offset,
int length)
bytes - the dataoffset - the offset in byteslength - the length in bytespublic void reset(int offset,
int length)
offset - the offset in byteslength - the length in bytespublic byte[] getData()
getReadPosition(),
getReadRemaining()public int getReadPosition()
public int getReadLimit()
public int getWritePosition()
public int getReadRemaining()
public void ensureCapacity(int newSize)
newSize - the required capacity in bytespublic int read()
throws IOException
-1 to no remained valuesIOException - if failed to read a valuepublic boolean readBoolean()
throws IOException
readBoolean in interface DataInputIOExceptionpublic byte readByte()
throws IOException
readByte in interface DataInputIOExceptionpublic int readUnsignedByte()
throws IOException
readUnsignedByte in interface DataInputIOExceptionpublic short readShort()
throws IOException
readShort in interface DataInputIOExceptionpublic int readUnsignedShort()
throws IOException
readUnsignedShort in interface DataInputIOExceptionpublic char readChar()
throws IOException
readChar in interface DataInputIOExceptionpublic int readInt()
throws IOException
readInt in interface DataInputIOExceptionpublic long readLong()
throws IOException
readLong in interface DataInputIOExceptionpublic float readFloat()
throws IOException
readFloat in interface DataInputIOExceptionpublic double readDouble()
throws IOException
readDouble in interface DataInputIOExceptionpublic void readFully(byte[] b)
throws IOException
readFully in interface DataInputIOExceptionpublic void readFully(byte[] b,
int off,
int len)
throws IOException
readFully in interface DataInputIOExceptionpublic int skipBytes(int n)
throws IOException
skipBytes in interface DataInputIOExceptionpublic String readLine() throws IOException
readLine in interface DataInputIOExceptionpublic String readUTF() throws IOException
readUTF in interface DataInputIOExceptionpublic void write(int b)
throws IOException
write in interface DataOutputIOExceptionpublic void write(byte[] b)
throws IOException
write in interface DataOutputIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in interface DataOutputIOExceptionpublic void writeBoolean(boolean v)
throws IOException
writeBoolean in interface DataOutputIOExceptionpublic void writeByte(int v)
throws IOException
writeByte in interface DataOutputIOExceptionpublic void writeShort(int v)
throws IOException
writeShort in interface DataOutputIOExceptionpublic void writeChar(int v)
throws IOException
writeChar in interface DataOutputIOExceptionpublic void writeInt(int v)
throws IOException
writeInt in interface DataOutputIOExceptionpublic void writeLong(long v)
throws IOException
writeLong in interface DataOutputIOExceptionpublic void writeFloat(float v)
throws IOException
writeFloat in interface DataOutputIOExceptionpublic void writeDouble(double v)
throws IOException
writeDouble in interface DataOutputIOExceptionpublic void writeBytes(String s) throws IOException
writeBytes in interface DataOutputIOExceptionpublic void writeChars(String s) throws IOException
writeChars in interface DataOutputIOExceptionpublic void writeUTF(String s) throws IOException
writeUTF in interface DataOutputIOExceptionpublic void write(DataInput in, int len) throws IOException
DataInput.in - the source inputlen - data size in bytesIOException - if failed to read DataInputCopyright © 2011–2019 Asakusa Framework Team. All rights reserved.