public class ByteArrayHandle extends AbstractNIOHandle
IRandomAccess
Modifier and Type | Field and Description |
---|---|
protected java.nio.ByteBuffer |
buffer
Backing ByteBuffer.
|
protected static int |
INITIAL_LENGTH
Initial length of a new file.
|
EOF_ERROR_MSG
Constructor and Description |
---|
ByteArrayHandle()
Creates a random access byte stream to write to a byte array.
|
ByteArrayHandle(byte[] bytes)
Creates a random access byte stream to read from, and
write to, the bytes specified by the byte[] argument.
|
ByteArrayHandle(java.nio.ByteBuffer bytes) |
ByteArrayHandle(int capacity)
Creates a random access byte stream to read from, and write to.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this random access stream and releases
any system resources associated with the stream.
|
java.nio.ByteBuffer |
getByteBuffer()
Gets the byte buffer backing this handle.
|
byte[] |
getBytes()
Gets the byte array backing this FileHandle.
|
long |
getFilePointer()
Returns the current offset in this stream.
|
java.nio.ByteOrder |
getOrder()
Returns the current order of the stream.
|
long |
length()
Returns the length of this stream.
|
int |
read(byte[] b)
Reads up to b.length bytes of data
from this stream into an array of bytes.
|
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from this stream into an array of bytes.
|
int |
read(java.nio.ByteBuffer buf)
Reads up to buffer.capacity() bytes of data
from this stream into a ByteBuffer.
|
int |
read(java.nio.ByteBuffer buf,
int off,
int len)
Reads up to len bytes of data from this stream into a ByteBuffer.
|
boolean |
readBoolean() |
byte |
readByte() |
char |
readChar() |
double |
readDouble() |
float |
readFloat() |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
int |
readInt() |
java.lang.String |
readLine() |
long |
readLong() |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
java.lang.String |
readUTF() |
void |
seek(long pos)
Sets the stream pointer offset, measured from the beginning
of this stream, at which the next read or write occurs.
|
void |
setLength(long length)
Sets the new length of the handle.
|
void |
setOrder(java.nio.ByteOrder order)
Sets the byte order of the stream.
|
int |
skipBytes(int n) |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(java.nio.ByteBuffer buf)
Writes up to buffer.capacity() bytes of data from the given
ByteBuffer to this stream.
|
void |
write(java.nio.ByteBuffer buf,
int off,
int len)
Writes up to len bytes of data from the given ByteBuffer to this
stream.
|
void |
write(int b) |
void |
writeBoolean(boolean v) |
void |
writeByte(int v) |
void |
writeBytes(java.lang.String s) |
void |
writeChar(int v) |
void |
writeChars(java.lang.String s) |
void |
writeDouble(double v) |
void |
writeFloat(float v) |
void |
writeInt(int v) |
void |
writeLong(long v) |
void |
writeShort(int v) |
void |
writeUTF(java.lang.String str) |
validateLength, validateMode
protected static final int INITIAL_LENGTH
protected java.nio.ByteBuffer buffer
public ByteArrayHandle(byte[] bytes)
public ByteArrayHandle(java.nio.ByteBuffer bytes)
public ByteArrayHandle(int capacity)
capacity
- Number of bytes to initially allocate.public ByteArrayHandle()
public byte[] getBytes()
public java.nio.ByteBuffer getByteBuffer()
public void setLength(long length) throws java.io.IOException
AbstractNIOHandle
setLength
in class AbstractNIOHandle
length
- New length.java.io.IOException
- If there is an error changing the handle's length.public void close()
IRandomAccess
public long getFilePointer()
IRandomAccess
public long length()
IRandomAccess
public int read(byte[] b) throws java.io.IOException
IRandomAccess
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
IRandomAccess
java.io.IOException
public int read(java.nio.ByteBuffer buf) throws java.io.IOException
IRandomAccess
java.io.IOException
public int read(java.nio.ByteBuffer buf, int off, int len) throws java.io.IOException
IRandomAccess
java.io.IOException
public void seek(long pos) throws java.io.IOException
IRandomAccess
java.io.IOException
public java.nio.ByteOrder getOrder()
IRandomAccess
public void setOrder(java.nio.ByteOrder order)
IRandomAccess
order
- Order to set.public boolean readBoolean() throws java.io.IOException
java.io.IOException
public byte readByte() throws java.io.IOException
java.io.IOException
public char readChar() throws java.io.IOException
java.io.IOException
public double readDouble() throws java.io.IOException
java.io.IOException
public float readFloat() throws java.io.IOException
java.io.IOException
public void readFully(byte[] b) throws java.io.IOException
java.io.IOException
public void readFully(byte[] b, int off, int len) throws java.io.IOException
java.io.IOException
public int readInt() throws java.io.IOException
java.io.IOException
public java.lang.String readLine() throws java.io.IOException
java.io.IOException
public long readLong() throws java.io.IOException
java.io.IOException
public short readShort() throws java.io.IOException
java.io.IOException
public int readUnsignedByte() throws java.io.IOException
java.io.IOException
public int readUnsignedShort() throws java.io.IOException
java.io.IOException
public java.lang.String readUTF() throws java.io.IOException
java.io.IOException
public int skipBytes(int n) throws java.io.IOException
java.io.IOException
public void write(byte[] b) throws java.io.IOException
java.io.IOException
public void write(byte[] b, int off, int len) throws java.io.IOException
java.io.IOException
public void write(java.nio.ByteBuffer buf) throws java.io.IOException
IRandomAccess
java.io.IOException
public void write(java.nio.ByteBuffer buf, int off, int len) throws java.io.IOException
IRandomAccess
java.io.IOException
public void write(int b) throws java.io.IOException
java.io.IOException
public void writeBoolean(boolean v) throws java.io.IOException
java.io.IOException
public void writeByte(int v) throws java.io.IOException
java.io.IOException
public void writeBytes(java.lang.String s) throws java.io.IOException
java.io.IOException
public void writeChar(int v) throws java.io.IOException
java.io.IOException
public void writeChars(java.lang.String s) throws java.io.IOException
java.io.IOException
public void writeDouble(double v) throws java.io.IOException
java.io.IOException
public void writeFloat(float v) throws java.io.IOException
java.io.IOException
public void writeInt(int v) throws java.io.IOException
java.io.IOException
public void writeLong(long v) throws java.io.IOException
java.io.IOException
public void writeShort(int v) throws java.io.IOException
java.io.IOException
public void writeUTF(java.lang.String str) throws java.io.IOException
java.io.IOException
Copyright © 2014 Open Microscopy Environment