public class FileDataSourceViaHeapImpl extends Object implements DataSource
| Constructor and Description |
|---|
FileDataSourceViaHeapImpl(File f) |
FileDataSourceViaHeapImpl(FileChannel fc) |
FileDataSourceViaHeapImpl(FileChannel fc,
String filename) |
FileDataSourceViaHeapImpl(String f) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Tries to free all resources.
|
ByteBuffer |
map(long startPosition,
long size)
Maps a part of this
DataSource into a ByteBuffer. |
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.
|
String |
toString() |
long |
transferTo(long startPosition,
long count,
WritableByteChannel sink)
Transfers bytes from this DataSource to the given writable byte
channel.
|
public FileDataSourceViaHeapImpl(File f) throws FileNotFoundException
FileNotFoundExceptionpublic FileDataSourceViaHeapImpl(String f) throws FileNotFoundException
FileNotFoundExceptionpublic FileDataSourceViaHeapImpl(FileChannel fc)
public FileDataSourceViaHeapImpl(FileChannel fc, String filename)
public int read(ByteBuffer byteBuffer) throws IOException
DataSourceread in interface DataSourcebyteBuffer - sink for this read operationIOException - If some I/O error occurspublic long size()
throws IOException
DataSourcesize in interface DataSourceIOException - If some I/O error occurspublic long position()
throws IOException
DataSourceposition in interface DataSourceIOException - If some I/O error occurspublic 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 startPosition,
long count,
WritableByteChannel sink)
throws IOException
DataSourcetransferTo in interface DataSourcestartPosition - 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-negativesink - The target channelIOException - If some I/O error occurspublic ByteBuffer map(long startPosition, long size) throws IOException
DataSourceDataSource into a ByteBuffer. It might utilize
an operating system supported memory mapped file or potentially just reads the requested
portion of the file into the memory.map in interface DataSourcestartPosition - where the requested block startsize - size of the requested blockDataSourceIOException - If some I/O error occurspublic void close()
throws IOException
DataSourceclose in interface DataSourceclose in interface Closeableclose in interface AutoCloseableIOException - If some I/O error occursCopyright © 2016. All rights reserved.