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 POIFSDataSourcebacked 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 voidclose()Close the underlying streamvoidcopyTo(OutputStream stream)Copies the contents to the specified OutputStreamFileChannelgetChannel()booleanisWriteable()ByteBufferread(int length, long position)voidreleaseBuffer(ByteBuffer buffer)longsize()voidwrite(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:
readin classDataSource- Throws:
IOException
-
write
public void write(ByteBuffer src, long position) throws IOException
- Specified by:
writein classDataSource- Throws:
IOException
-
copyTo
public void copyTo(OutputStream stream) throws IOException
Description copied from class:DataSourceCopies the contents to the specified OutputStream- Specified by:
copyToin classDataSource- Throws:
IOException
-
size
public long size() throws IOException- Specified by:
sizein classDataSource- Throws:
IOException
-
releaseBuffer
public void releaseBuffer(ByteBuffer buffer)
-
close
public void close() throws IOExceptionDescription copied from class:DataSourceClose the underlying stream- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classDataSource- Throws:
IOException
-
-