public final class BufferedFileChannelInputStream
extends java.io.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, see BufferedFileChannelInputStream.Builder
.
This class was ported and adapted from Apache Spark commit 933dc6cb7b3de1d8ccaf73d124d6eb95b947ed19 where it was called NioBufferedFileInputStream
.
Modifier and Type | Class and Description |
---|---|
static class |
BufferedFileChannelInputStream.Builder
Builds a new
BufferedFileChannelInputStream instance. |
Constructor and Description |
---|
BufferedFileChannelInputStream(java.io.File file)
Deprecated.
|
BufferedFileChannelInputStream(java.io.File file,
int bufferSize)
Deprecated.
|
BufferedFileChannelInputStream(java.nio.file.Path path)
Deprecated.
|
BufferedFileChannelInputStream(java.nio.file.Path path,
int bufferSize)
Deprecated.
|
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) |
@Deprecated public BufferedFileChannelInputStream(java.io.File file) throws java.io.IOException
builder()
, BufferedFileChannelInputStream.Builder
, and BufferedFileChannelInputStream.Builder.get()
file
- The file to stream.java.io.IOException
- If an I/O error occurs@Deprecated public BufferedFileChannelInputStream(java.io.File file, int bufferSize) throws java.io.IOException
builder()
, BufferedFileChannelInputStream.Builder
, and BufferedFileChannelInputStream.Builder.get()
file
- The file to stream.bufferSize
- buffer size.java.io.IOException
- If an I/O error occurs@Deprecated public BufferedFileChannelInputStream(java.nio.file.Path path) throws java.io.IOException
builder()
, BufferedFileChannelInputStream.Builder
, and BufferedFileChannelInputStream.Builder.get()
path
- The path to stream.java.io.IOException
- If an I/O error occurs@Deprecated public BufferedFileChannelInputStream(java.nio.file.Path path, int bufferSize) throws java.io.IOException
builder()
, BufferedFileChannelInputStream.Builder
, and BufferedFileChannelInputStream.Builder.get()
path
- The path to stream.bufferSize
- buffer size.java.io.IOException
- If an I/O error occurspublic static BufferedFileChannelInputStream.Builder builder()
BufferedFileChannelInputStream.Builder
.BufferedFileChannelInputStream.Builder
.public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b, int offset, int len) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public long skip(long n) throws java.io.IOException
skip
in class java.io.InputStream
java.io.IOException
Copyright © 2010 - 2023 Adobe. All Rights Reserved