public class FileByteSource extends Object implements ByteSource
Example Usage:
ByteSource src = new FileByteSource("/tmp/data.bin");
AsyncIterator.forEach( src::read, System.out::println )
.finally_( src::close );
Each FileByteSource depends on an AsynchronousFileChannel, obtained from a FileByteSource.ChannelProvider.| Modifier and Type | Class and Description |
|---|---|
static interface |
FileByteSource.ChannelProvider
Provider of AsynchronousFileChannel for FileByteSource.
|
| Constructor and Description |
|---|
FileByteSource(Path filePath)
Create a FileByteSource.
|
FileByteSource(String filePath)
Create a FileByteSource.
|
FileByteSource(FileByteSource.ChannelProvider channelProvider)
Create a FileByteSource.
|
| Instance Methods | |
|---|---|
long |
skip(long n)
Try to skip forward `n` bytes.
|
Async<ByteBuffer> |
read()
Read the next chunk of bytes.
|
Async<Void> |
close()
Close this source.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitasString, asString, readAll, toSinkpublic FileByteSource(Path filePath)
public FileByteSource(String filePath)
public FileByteSource(FileByteSource.ChannelProvider channelProvider)
The `channelProvider` will provide an `AsynchronousFileChannel` for this source.
public long skip(long n)
throws IllegalArgumentException,
IllegalStateException
skip in interface ByteSourcen - number of bytes to skip; n >= 0.0 <= m <= n.IllegalStateException - if this source is closed.IllegalArgumentException - if n < 0.public Async<ByteBuffer> read() throws IllegalStateException
read in interface ByteSourceIllegalStateException - if this source is closed.public Async<Void> close()
close in interface ByteSource