Package io.scanbot.sdk.io
Class RandomAccessSource
- java.lang.Object
-
- io.scanbot.sdk.io.RandomAccessSource
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class RandomAccessSource extends java.lang.Object implements java.lang.AutoCloseableRandomAccessSource is a wrapper around a native memory-mapped file or byte array. It is used to provide a random access interface to the underlying data.
-
-
Constructor Summary
Constructors Constructor Description RandomAccessSource(byte[] data)Constructs RandomAccessSource from the given byte array.RandomAccessSource(java.io.InputStream inputStream)Constructs RandomAccessSource from the given InputStream effectively reading the whole stream into memory.RandomAccessSource(java.lang.String filePath)Constructs RandomAccessSource from the given file effectively creating a memory-mapping.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes native resources held by the object.protected voidfinalize()
-
-
-
Constructor Detail
-
RandomAccessSource
public RandomAccessSource(java.lang.String filePath) throws java.io.IOExceptionConstructs RandomAccessSource from the given file effectively creating a memory-mapping. If the desired source is indeed a file on disk, you should prefer this constructor over the InputStream one as memory mapping allows more memory consumption efficient processing.- Parameters:
filePath- path to the file- Throws:
java.io.IOException- if the file memory mapping fails (e.g. because the file does not exist)
-
RandomAccessSource
public RandomAccessSource(byte[] data)
Constructs RandomAccessSource from the given byte array.- Parameters:
data- the byte array to use as the source
-
RandomAccessSource
public RandomAccessSource(java.io.InputStream inputStream) throws java.io.IOExceptionConstructs RandomAccessSource from the given InputStream effectively reading the whole stream into memory. If your original source is an InputStream you should prefer this constructor over creating a java byte array and using the byte array constructor.- Parameters:
inputStream- the input stream to read from- Throws:
java.io.IOException- if reading from the stream fails
-
-