public class PdfInputFile extends java.lang.Object implements PdfInput
PdfReader
accesses PDF documents through the
PdfInput
interface, which is implemented by this
class. The portions of the document are read from the file system
as they are requested, which reduces memory consumption as compared
to PdfInputBuffer
but is a bit slower.
This class is synchronized; however, note that since it acts as a
wrapper around a file that is kept open, it is the calling method's
responsibility to ensure that the file is not modified externally
to this class. If that is a problem, use PdfInputBuffer.PdfInputBuffer(File)
, which reads the entire file
into memory and closes it immediately.
Modifier and Type | Field and Description |
---|---|
protected java.nio.channels.FileChannel |
_fileChannel
The file channel associated with the PDF document.
|
protected long |
_length
The length of the input file.
|
protected java.lang.String |
_name
The input file name.
|
protected java.io.RandomAccessFile |
_randomAccessFile
The random access file containing the PDF document.
|
Constructor and Description |
---|
PdfInputFile(java.io.File pdfFile)
Constructs a PDF input source based on a specified file.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the PDF document and releases any system resources
associated with it.
|
long |
getLength()
Returns the length of the PDF document.
|
java.lang.String |
getName()
Returns a name string associated of the PDF document.
|
java.nio.ByteBuffer |
readBytes(long start,
long end)
Returns a specified portion of a PDF document as a
ByteBuffer . |
java.nio.CharBuffer |
readChars(long start,
long end)
Returns a specified portion of a PDF document as a
CharBuffer . |
protected java.nio.channels.FileChannel _fileChannel
protected long _length
protected java.lang.String _name
protected java.io.RandomAccessFile _randomAccessFile
public PdfInputFile(java.io.File pdfFile) throws java.io.IOException
pdfFile
- the source file.java.io.IOException
public void close() throws java.io.IOException
java.io.IOException
public long getLength()
PdfInput
public java.nio.ByteBuffer readBytes(long start, long end) throws java.io.IOException
PdfInput
ByteBuffer
.public java.nio.CharBuffer readChars(long start, long end) throws java.io.IOException
PdfInput
CharBuffer
.