sys::Obj sys::Buf
public final class Buf
Buf encapsulates a fixed capacity byte[]. The fixed capacity is available via the 'bytesLen' field. At any time a variable number of bytes are actually used as defined by the 'size' field. Use the BufInStream and BufOutStream classes to perform memory based IO against a Buf instance.
public inline byte[] bytes
public short bytesLen
public short size
public void Buf(int maxBufLen)
Construct a buffer with the specified maximum size.
public void clear()
Set size to zero. The data remains untouched, but the buffer is ready to be used to begin writing from scratch.
public void copyFromBuf(Buf that)
Copy the specified buffer bytes into this buffer's bytes and update size. If the specified buffer contains more than bytesLen bytes then the copy is truncated.
public void copyFromBytes(byte[] that, int off, int len)
Copy the specified byte array into this buffer's bytes and update size. If the specified length is greater than bytesLen bytes then the copy is truncated.
public bool copyFromStr(Str s)
Copy the specified string including its null terminator into this buffer bytes field and update size accordingly. If the specified string contains more than bytesLen characters including the null terminator then return false and truncate the copy. If truncated we still add a null terminator.
public int get(int index)
Get the byte at the specified index.
public Str toStr() [javaNative]
Return the bytes cast to a Str reference. No guarantee is made whether the string is actually null terminated.