Package javaforce
Class JFByteBuffer
java.lang.Object
javaforce.JFByteBuffer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintBytes that can be written (appended).voidcompact()Moves any data left in the buffer to the start of the buffer.byte[]Returns underlying byte buffer.intBytes that can read.intReturns read offset in buffer.intindexOf(byte[] key) Searches for key and returns index.bytereadByte()Read one byte.booleanreadBytes(byte[] out, int off, int len) Reads bytes placing them in out array.intreadBytes(OutputStream os, int max_bytes) Reads bytes placing them in OutputStream.intreadInt()Read one int.longreadLong()Read one long.shortRead one short.readString(int strlen) Reads a string of specified length.voidreset()Resets buffer length and read/write offsets.voidskip(int bytes) Skips bytesbooleanstartsWith(byte[] key) Checks if buffer starts with key bytes.booleanwrite(byte b) Write (appends) one byte.booleanwrite(byte[] in, int off, int len) Appends in array to buffer.booleanwrite(int len) Writes (appends) one int.booleanwrite(long len) Writes (appends) one long.booleanwrite(short len) Writes (appends) one short.intwrite(InputStream is, int max_bytes) Appends bytes from InputStream to buffer.booleanAppends string to buffer.
-
Constructor Details
-
JFByteBuffer
public JFByteBuffer(int max_length)
-
-
Method Details
-
reset
public void reset()Resets buffer length and read/write offsets. -
getBuffer
public byte[] getBuffer()Returns underlying byte buffer. -
getOffset
public int getOffset()Returns read offset in buffer. -
getLength
public int getLength()Bytes that can read. -
available
public int available()Bytes that can be written (appended). -
compact
public void compact()Moves any data left in the buffer to the start of the buffer. -
indexOf
public int indexOf(byte[] key) Searches for key and returns index. Returns -1 if not found. -
startsWith
public boolean startsWith(byte[] key) Checks if buffer starts with key bytes. -
skip
public void skip(int bytes) Skips bytes -
readByte
public byte readByte()Read one byte. Returns -1 if buffer is empty. -
readShort
public short readShort()Read one short. Returns -1 if buffer is empty. -
readInt
public int readInt()Read one int. Returns -1 if buffer is empty. -
readLong
public long readLong()Read one long. Returns -1 if buffer is empty. -
readBytes
public boolean readBytes(byte[] out, int off, int len) Reads bytes placing them in out array. -
readBytes
Reads bytes placing them in OutputStream. -
readString
Reads a string of specified length. -
write
public boolean write(byte b) Write (appends) one byte. -
write
public boolean write(short len) Writes (appends) one short. -
write
public boolean write(int len) Writes (appends) one int. -
write
public boolean write(long len) Writes (appends) one long. -
write
public boolean write(byte[] in, int off, int len) Appends in array to buffer. -
write
Appends string to buffer. -
write
Appends bytes from InputStream to buffer.
-