public interface DataSource extends Closeable
Modifier and Type | Method and Description |
---|---|
void |
close() |
ByteBuffer |
map(long startPosition,
long size) |
long |
position()
Returns the DataSource's current position.
|
void |
position(long nuPos)
Sets the DataSource's position.
|
int |
read(ByteBuffer byteBuffer)
Reads a sequence of bytes from this channel into the given buffer.
|
long |
size()
Returns the current size of this DataSource.
|
long |
transferTo(long position,
long count,
WritableByteChannel target)
Transfers bytes from this DataSource to the given writable byte
channel.
|
int read(ByteBuffer byteBuffer) throws IOException
Bytes are read starting at this channel's current position, and then the file position is updated with the number of bytes actually read.
IOException
long size() throws IOException
IOException
- If some I/O error occurslong position() throws IOException
IOException
void position(long nuPos) throws IOException
nuPos
- The new position, a non-negative integer counting
the number of bytes from the beginning of the dataIOException
- If some I/O error occurslong transferTo(long position, long count, WritableByteChannel target) throws IOException
An attempt should be made to read up to count bytes starting at the given position in this DataSource and write them to the target channel. An invocation of this method may or may not transfer all of the requested bytes;
position
- The position within the DataSource at which the transfer is to begin;
must be non-negativecount
- The maximum number of bytes to be transferred; must be
non-negativetarget
- The target channelIOException
ByteBuffer map(long startPosition, long size) throws IOException
startPosition
- size
- IOException
void close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
IOException
Copyright © 2014. All rights reserved.