java.lang.Object
org.sejda.io.SeekableSources
This class consists of solely static methods to create the most appropriate
SeekableSource based on the given input or to bridge SeekableSources to the more
traditional InputStream or other standard I/O classes.- Author:
- Andrea Vacondio
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThreshold size in bytes where the SeekableSources method will switch toMemoryMappedSeekableSource(File)static final StringBuffer size forBufferedSeekableSourcestatic final StringThreshold size in bytes where the SeekableSources method will switch toMemoryMappedSeekableSource(File)static final StringSize of the pages used byMemoryMappedSeekableSource -
Method Summary
Modifier and TypeMethodDescriptionstatic OffsettableSeekableSourceasOffsettable(SeekableSource source) Factory method to create anOffsettableSeekableSourcefrom aSeekableSourcestatic SeekableSourceinMemorySeekableSourceFrom(byte[] bytes) Factory method to create aSeekableSourcefrom a byte array.static SeekableSourceFactory method to create aSeekableSourcefrom aInputStream.static SeekableSourceFactory method to create aSeekableSourcefrom aInputStream.static SeekableSourceonTempFileSeekableSourceFrom(InputStream stream, String filenameHint) Factory method to create aSeekableSourcefrom aInputStream.static SeekableSourceseekableSourceFrom(File file) Factory method to create aSeekableSourcefrom aFile.static SeekableSourceseekableSourceFrom(Path path) Factory method to create aSeekableSourcefrom aPath.
-
Field Details
-
MAPPED_SIZE_THRESHOLD_PROPERTY
Threshold size in bytes where the SeekableSources method will switch toMemoryMappedSeekableSource(File)- See Also:
-
DISABLE_MEMORY_MAPPED_PROPERTY
Threshold size in bytes where the SeekableSources method will switch toMemoryMappedSeekableSource(File)- See Also:
-
INPUT_BUFFER_SIZE_PROPERTY
Buffer size forBufferedSeekableSource- See Also:
-
MEMORY_MAPPED_PAGE_SIZE_PROPERTY
Size of the pages used byMemoryMappedSeekableSource- See Also:
-
-
Method Details
-
seekableSourceFrom
Factory method to create aSeekableSourcefrom aFile. An attempt is made to return the bestSeekableSourceimplementation based on the size of the file and bitness of the JVM.- Parameters:
file-- Returns:
- a
SeekableSourcefrom the given file. - Throws:
IOException
-
seekableSourceFrom
Factory method to create aSeekableSourcefrom aPath. An attempt is made to return the bestSeekableSourceimplementation based on the size of the file and bitness of the JVM.- Parameters:
path-- Returns:
- a
SeekableSourcefrom the given file. - Throws:
IOException
-
inMemorySeekableSourceFrom
Factory method to create aSeekableSourcefrom aInputStream. The whole stream is read and stored in a byte array with a max size of 2GB.- Parameters:
stream-- Returns:
- a
SeekableSourcefrom the given stream. - Throws:
IOException
-
inMemorySeekableSourceFrom
Factory method to create aSeekableSourcefrom a byte array.- Parameters:
bytes-- Returns:
- a
SeekableSourcewrapping the given byte array.
-
onTempFileSeekableSourceFrom
Factory method to create aSeekableSourcefrom aInputStream. The whole stream is copied to a temporary file.- Parameters:
stream-- Returns:
- a
SeekableSourcefrom the given stream. - Throws:
IOException
-
onTempFileSeekableSourceFrom
public static SeekableSource onTempFileSeekableSourceFrom(InputStream stream, String filenameHint) throws IOException Factory method to create aSeekableSourcefrom aInputStream. The whole stream is copied to a temporary file.- Parameters:
stream-filenameHint- name to use for the temp file that will be created- Returns:
- a
SeekableSourcefrom the given stream. - Throws:
IOException
-
asOffsettable
Factory method to create anOffsettableSeekableSourcefrom aSeekableSource- Parameters:
source-- Returns:
-