| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: recommended alignment size for randomly positioned reads. Does not need to be a power of 2.Get the recommended alignment for reads. |
| public long | |
| public void | position(long
position to move the channel to. The next read will start from
here. This should be a multiple of the newPosition)blockSize().Seek the current position of the channel to a new offset. |
| public void | setReadAheadBytes(int
requested size of the read ahead buffer, in bytes. bufferSize)Recommend the channel maintain a read-ahead buffer. |
| public long | Returns: r total size of the channel; -1 if not yet available.Get the total size of the channel. |
| blockSize | back to summary |
|---|---|
| public int blockSize() Get the recommended alignment for reads. Starting a read at multiples of the blockSize is more efficient than starting a read at any other position. If 0 or -1 the channel does not have any specific block size recommendation.
Channels should not recommend large block sizes. Sizes up to 1-4 MiB may
be reasonable, but sizes above that may be horribly inefficient. The
| |
| position | back to summary |
|---|---|
| public long position() throws IOException Get the current position of the channel.
| |
| position | back to summary |
|---|---|
| public void position(long newPosition) throws IOException Seek the current position of the channel to a new offset.
| |
| setReadAheadBytes | back to summary |
|---|---|
| public void setReadAheadBytes(int bufferSize) throws IOException Recommend the channel maintain a read-ahead buffer.
A read-ahead buffer of approximately
Callers can continue to read in smaller than To avoid unnecessary IO callers should only enable read-ahead if the majority of the channel will be accessed in order. Implementations may chose to read-ahead using asynchronous APIs or background threads, or may simply aggregate reads using a buffer. This read ahead stays in effect until the channel is closed or the buffer size is set to 0.
| |
| size | back to summary |
|---|---|
| public long size() throws IOException Get the total size of the channel. Prior to reading from a channel the size might not yet be known. Implementors may return -1 until after the first read method call. Once a read has been completed, the underlying file size should be available.
| |