public final class BufferedFileChannelInputStream extends InputStream
InputStream implementation which uses direct buffer to read a file to avoid extra copy of data between Java and native memory which happens when
using BufferedInputStream. Unfortunately, this is not something already available in JDK, sun.nio.ch.ChannelInputStream supports
reading a file using NIO, but does not support buffering.
To build an instance, use BufferedFileChannelInputStream.Builder.
This class was ported and adapted from Apache Spark commit 933dc6cb7b3de1d8ccaf73d124d6eb95b947ed19 where it was called NioBufferedFileInputStream.
BufferedFileChannelInputStream.Builder| Modifier and Type | Class and Description |
|---|---|
static class |
BufferedFileChannelInputStream.Builder
Builds a new
BufferedFileChannelInputStream. |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
static BufferedFileChannelInputStream.Builder |
builder()
Constructs a new
BufferedFileChannelInputStream.Builder. |
void |
close() |
int |
read() |
int |
read(byte[] b,
int offset,
int len) |
long |
skip(long n) |
mark, markSupported, read, resetpublic int available()
throws IOException
available in class InputStreamIOExceptionpublic static BufferedFileChannelInputStream.Builder builder()
BufferedFileChannelInputStream.Builder.BufferedFileChannelInputStream.Builder.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b,
int offset,
int len)
throws IOException
read in class InputStreamIOExceptionpublic long skip(long n)
throws IOException
skip in class InputStreamIOException