public final class TByteBuffer extends TTransport
Constructor and Description |
---|
TByteBuffer(java.nio.ByteBuffer byteBuffer)
Creates a new TByteBuffer wrapping a given NIO ByteBuffer.
|
Modifier and Type | Method and Description |
---|---|
TByteBuffer |
clear()
Convenience method to call clear() on the underlying NIO ByteBuffer.
|
void |
close()
Closes the transport.
|
TByteBuffer |
flip()
Convenience method to call flip() on the underlying NIO ByteBuffer.
|
java.nio.ByteBuffer |
getByteBuffer()
Get the underlying NIO ByteBuffer.
|
boolean |
isOpen()
Queries whether the transport is open.
|
void |
open()
Opens the transport for reading/writing.
|
int |
read(byte[] buf,
int off,
int len)
Reads up to len bytes into buffer buf, starting at offset off.
|
byte[] |
toByteArray()
Convenience method to convert the underlying NIO ByteBuffer to a
plain old byte array.
|
void |
write(byte[] buf,
int off,
int len)
Writes up to len bytes from the buffer.
|
consumeBuffer, flush, getBuffer, getBufferPosition, getBytesRemainingInBuffer, peek, readAll, write
public TByteBuffer(java.nio.ByteBuffer byteBuffer)
public boolean isOpen()
TTransport
isOpen
in class TTransport
public void open()
TTransport
open
in class TTransport
public void close()
TTransport
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class TTransport
public int read(byte[] buf, int off, int len) throws TTransportException
TTransport
read
in class TTransport
buf
- Array to read intooff
- Index to start reading atlen
- Maximum number of bytes to readTTransportException
- if there was an error reading datapublic void write(byte[] buf, int off, int len) throws TTransportException
TTransport
write
in class TTransport
buf
- The output data bufferoff
- The offset to start writing fromlen
- The number of bytes to writeTTransportException
- if there was an error writing datapublic java.nio.ByteBuffer getByteBuffer()
public TByteBuffer clear()
public TByteBuffer flip()
public byte[] toByteArray()