Package org.apache.poi.poifs.nio
Class FileBackedDataSource
- java.lang.Object
-
- org.apache.poi.poifs.nio.DataSource
-
- org.apache.poi.poifs.nio.FileBackedDataSource
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class FileBackedDataSource extends DataSource implements Closeable
A POIFSDataSource
backed by a File
-
-
Constructor Summary
Constructors Constructor Description FileBackedDataSource(File file)
FileBackedDataSource(File file, boolean readOnly)
FileBackedDataSource(RandomAccessFile srcFile, boolean readOnly)
FileBackedDataSource(FileChannel channel, boolean readOnly)
FileBackedDataSource(FileChannel channel, boolean readOnly, boolean closeChannelOnClose)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the underlying streamvoid
copyTo(OutputStream stream)
Copies the contents to the specified OutputStreamFileChannel
getChannel()
boolean
isWriteable()
ByteBuffer
read(int length, long position)
void
releaseBuffer(ByteBuffer buffer)
long
size()
void
write(ByteBuffer src, long position)
-
-
-
Constructor Detail
-
FileBackedDataSource
public FileBackedDataSource(File file) throws FileNotFoundException
- Throws:
FileNotFoundException
-
FileBackedDataSource
public FileBackedDataSource(File file, boolean readOnly) throws FileNotFoundException
- Throws:
FileNotFoundException
-
FileBackedDataSource
public FileBackedDataSource(RandomAccessFile srcFile, boolean readOnly)
-
FileBackedDataSource
public FileBackedDataSource(FileChannel channel, boolean readOnly)
-
FileBackedDataSource
public FileBackedDataSource(FileChannel channel, boolean readOnly, boolean closeChannelOnClose)
- Since:
- POI 5.1.0
-
-
Method Detail
-
isWriteable
public boolean isWriteable()
-
getChannel
public FileChannel getChannel()
-
read
public ByteBuffer read(int length, long position) throws IOException
- Specified by:
read
in classDataSource
- Throws:
IOException
-
write
public void write(ByteBuffer src, long position) throws IOException
- Specified by:
write
in classDataSource
- Throws:
IOException
-
copyTo
public void copyTo(OutputStream stream) throws IOException
Description copied from class:DataSource
Copies the contents to the specified OutputStream- Specified by:
copyTo
in classDataSource
- Throws:
IOException
-
size
public long size() throws IOException
- Specified by:
size
in classDataSource
- Throws:
IOException
-
releaseBuffer
public void releaseBuffer(ByteBuffer buffer)
-
close
public void close() throws IOException
Description copied from class:DataSource
Close the underlying stream- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classDataSource
- Throws:
IOException
-
-