public class FileDataSourceImpl extends Object implements DataSource
Constructor and Description |
---|
FileDataSourceImpl(File f) |
FileDataSourceImpl(FileChannel fc) |
FileDataSourceImpl(FileChannel fc,
String filename) |
FileDataSourceImpl(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 FileDataSourceImpl(File f) throws FileNotFoundException
FileNotFoundException
public FileDataSourceImpl(String f) throws FileNotFoundException
FileNotFoundException
public FileDataSourceImpl(FileChannel fc)
public FileDataSourceImpl(FileChannel fc, String filename)
public int read(ByteBuffer byteBuffer) throws IOException
DataSource
read
in interface DataSource
byteBuffer
- sink for this read operationIOException
- If some I/O error occurspublic long size() throws IOException
DataSource
size
in interface DataSource
IOException
- If some I/O error occurspublic long position() throws IOException
DataSource
position
in interface DataSource
IOException
- If some I/O error occurspublic void position(long nuPos) throws IOException
DataSource
position
in interface DataSource
nuPos
- 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
DataSource
transferTo
in interface DataSource
startPosition
- 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
DataSource
DataSource
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 DataSource
startPosition
- where the requested block startsize
- size of the requested blockDataSource
IOException
- If some I/O error occurspublic void close() throws IOException
DataSource
close
in interface DataSource
close
in interface Closeable
close
in interface AutoCloseable
IOException
- If some I/O error occursCopyright © 2015. All rights reserved.