public class MemoryDataSourceImpl extends Object implements DataSource
| Constructor and Description |
|---|
MemoryDataSourceImpl(byte[] data) |
MemoryDataSourceImpl(ByteBuffer buffer) |
| 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.
|
public MemoryDataSourceImpl(byte[] data)
public MemoryDataSourceImpl(ByteBuffer buffer)
public int read(ByteBuffer byteBuffer) throws IOException
DataSourceBytes are read starting at this channel's current position, and then the file position is updated with the number of bytes actually read.
read in interface DataSourceIOExceptionpublic long size()
throws IOException
DataSourcesize in interface DataSourceIOException - If some I/O error occurspublic long position()
throws IOException
DataSourceposition in interface DataSourceIOExceptionpublic void position(long nuPos)
throws IOException
DataSourceposition in interface DataSourcenuPos - The new position, a non-negative integer counting
the number of bytes from the beginning of the dataIOException - If some I/O error occurspublic long transferTo(long position,
long count,
WritableByteChannel target)
throws IOException
DataSourceAn 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;
transferTo in interface DataSourceposition - 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 channelIOExceptionpublic ByteBuffer map(long startPosition, long size) throws IOException
map in interface DataSourceIOExceptionpublic void close()
throws IOException
close in interface DataSourceclose in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2014. All rights reserved.