public class FileDataSourceImpl extends Object implements DataSource
| Constructor and Description |
|---|
FileDataSourceImpl(File f) |
FileDataSourceImpl(FileChannel fc) |
FileDataSourceImpl(String f) |
| 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 startPosition,
long count,
WritableByteChannel sink)
Transfers bytes from this DataSource to the given writable byte
channel.
|
public FileDataSourceImpl(File f) throws FileNotFoundException
FileNotFoundExceptionpublic FileDataSourceImpl(String f) throws FileNotFoundException
FileNotFoundExceptionpublic FileDataSourceImpl(FileChannel fc)
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 startPosition,
long count,
WritableByteChannel sink)
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 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 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.