Modifier and Type | Field and Description |
---|---|
private byte[] | |
private boolean | |
private int | |
private static final int | MAX_ARRAY_SIZE
The maximum size of array to allocate. |
private int | |
private boolean | |
private final ReadWriteLock |
Access | Constructor and Description |
---|---|
pack-priv | |
pack-priv |
Modifier and Type | Method and Description |
---|---|
private final void | |
pack-priv final void | |
public void | |
private final void | |
pack-priv final void | |
private void | |
private void | |
private void | grow(int
the desired minimum capacity minCapacity)Increases the capacity to ensure that it can hold at least the number of elements specified by the minimum capacity argument. |
private static int | |
public boolean | |
public long | position()
Implements java. |
public SeekableByteChannel | position(long
The new position, a non-negative integer counting
the number of bytes from the beginning of the entity pos)Implements java. |
public int | read(ByteBuffer
The buffer into which bytes are to be transferred dst)Implements java. |
public long | size()
Implements java. |
public byte[] | Returns: the current contents of this channel, as a byte array.Creates a newly allocated byte array. |
public SeekableByteChannel | truncate(long
The new size, a non-negative byte count size)Implements java. |
public int | write(ByteBuffer
The buffer from which bytes are to be retrieved src)Implements java. |
buf | back to summary |
---|---|
private byte[] buf |
closed | back to summary |
---|---|
private boolean closed |
last | back to summary |
---|---|
private int last |
MAX_ARRAY_SIZE | back to summary |
---|---|
private static final int MAX_ARRAY_SIZE The maximum size of array to allocate. Some VMs reserve some header words in an array. Attempts to allocate larger arrays may result in OutOfMemoryError: Requested array size exceeds VM limit |
pos | back to summary |
---|---|
private int pos |
readonly | back to summary |
---|---|
private boolean readonly |
rwlock | back to summary |
---|---|
private final ReadWriteLock rwlock |
ByteArrayChannel | back to summary |
---|---|
pack-priv ByteArrayChannel(int sz, boolean readonly) |
ByteArrayChannel | back to summary |
---|---|
pack-priv ByteArrayChannel(byte[] buf, boolean readonly) |
beginRead | back to summary |
---|---|
private final void beginRead() |
beginWrite | back to summary |
---|---|
pack-priv final void beginWrite() |
close | back to summary |
---|---|
public void close() throws IOException Implements java. Doc from java. Closes this channel. After a channel is closed, any further attempt to invoke I/O
operations upon it will cause a If this channel is already closed then invoking this method has no effect. This method may be invoked at any time. If some other thread has already invoked it, however, then another invocation will block until the first invocation is complete, after which it will return without effect.
|
endRead | back to summary |
---|---|
private final void endRead() |
endWrite | back to summary |
---|---|
pack-priv final void endWrite() |
ensureCapacity | back to summary |
---|---|
private void ensureCapacity(int minCapacity) |
ensureOpen | back to summary |
---|---|
private void ensureOpen() throws IOException |
grow | back to summary |
---|---|
private void grow(int minCapacity) Increases the capacity to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
|
hugeCapacity | back to summary |
---|---|
private static int hugeCapacity(int minCapacity) |
isOpen | back to summary |
---|---|
public boolean isOpen() Implements java. Doc from java. Tells whether or not this channel is open.
|
position | back to summary |
---|---|
public long position() throws IOException Implements java. Doc from java. Returns this channel's position.
|
position | back to summary |
---|---|
public SeekableByteChannel position(long pos) throws IOException Implements java. Doc from java. Sets this channel's position. Setting the position to a value that is greater than the current size is legal but does not change the size of the entity. A later attempt to read bytes at such a position will immediately return an end-of-file indication. A later attempt to write bytes at such a position will cause the entity to grow to accommodate the new bytes; the values of any bytes between the previous end-of-file and the newly-written bytes are unspecified. Setting the channel's position is not recommended when connected to
an entity, typically a file, that is opened with the
|
read | back to summary |
---|---|
public int read(ByteBuffer dst) throws IOException Implements java. Doc from java. Reads a sequence of bytes from this channel into the given buffer. Bytes are read starting at this channel's current position, and
then the position is updated with the number of bytes actually read.
Otherwise this method behaves exactly as specified in the
|
size | back to summary |
---|---|
public long size() throws IOException Implements java. Doc from java. Returns the current size of entity to which this channel is connected.
|
toByteArray | back to summary |
---|---|
public byte[] toByteArray() Creates a newly allocated byte array. Its size is the current size of this channel and the valid contents of the buffer have been copied into it.
|
truncate | back to summary |
---|---|
public SeekableByteChannel truncate(long size) throws IOException Implements java. Doc from java. Truncates the entity, to which this channel is connected, to the given size. If the given size is less than the current size then the entity is truncated, discarding any bytes beyond the new end. If the given size is greater than or equal to the current size then the entity is not modified. In either case, if the current position is greater than the given size then it is set to that size. An implementation of this interface may prohibit truncation when
connected to an entity, typically a file, opened with the
|
write | back to summary |
---|---|
public int write(ByteBuffer src) throws IOException Implements java. Doc from java. Writes a sequence of bytes to this channel from the given buffer. Bytes are written starting at this channel's current position, unless
the channel is connected to an entity such as a file that is opened with
the
|