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 DataInput
IOException
public byte readByte() throws IOException
readByte
in interface DataInput
IOException
public int readUnsignedByte() throws IOException
readUnsignedByte
in interface DataInput
IOException
public short readShort() throws IOException
readShort
in interface DataInput
IOException
public int readUnsignedShort() throws IOException
readUnsignedShort
in interface DataInput
IOException
public char readChar() throws IOException
readChar
in interface DataInput
IOException
public int readInt() throws IOException
readInt
in interface DataInput
IOException
public long readLong() throws IOException
readLong
in interface DataInput
IOException
public float readFloat() throws IOException
readFloat
in interface DataInput
IOException
public double readDouble() throws IOException
readDouble
in interface DataInput
IOException
public void readFully(byte[] b) throws IOException
readFully
in interface DataInput
IOException
public void readFully(byte[] b, int off, int len) throws IOException
readFully
in interface DataInput
IOException
public int skipBytes(int n) throws IOException
skipBytes
in interface DataInput
IOException
public String readLine() throws IOException
readLine
in interface DataInput
IOException
public String readUTF() throws IOException
readUTF
in interface DataInput
IOException
public void write(int b) throws IOException
write
in interface DataOutput
IOException
public void write(byte[] b) throws IOException
write
in interface DataOutput
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in interface DataOutput
IOException
public void writeBoolean(boolean v) throws IOException
writeBoolean
in interface DataOutput
IOException
public void writeByte(int v) throws IOException
writeByte
in interface DataOutput
IOException
public void writeShort(int v) throws IOException
writeShort
in interface DataOutput
IOException
public void writeChar(int v) throws IOException
writeChar
in interface DataOutput
IOException
public void writeInt(int v) throws IOException
writeInt
in interface DataOutput
IOException
public void writeLong(long v) throws IOException
writeLong
in interface DataOutput
IOException
public void writeFloat(float v) throws IOException
writeFloat
in interface DataOutput
IOException
public void writeDouble(double v) throws IOException
writeDouble
in interface DataOutput
IOException
public void writeBytes(String s) throws IOException
writeBytes
in interface DataOutput
IOException
public void writeChars(String s) throws IOException
writeChars
in interface DataOutput
IOException
public void writeUTF(String s) throws IOException
writeUTF
in interface DataOutput
IOException
public void write(DataInput in, int len) throws IOException
DataInput
.in
- the source inputlen
- data size in bytesIOException
- if failed to read DataInput
Copyright © 2011–2019 Asakusa Framework Team. All rights reserved.