public class MatFileReader extends Object
MLArray objects.
Usage:
//read in the file
MatFileReader mfr = new MatFileReader( "mat_file.mat" );
//get array of a name "my_array" from file
MLArray mlArrayRetrived = mfr.getMLArray( "my_array" );
//or get the collection of all arrays that were stored in the file
Map content = mfr.getContent();
MatFileFilter| Modifier and Type | Field and Description |
|---|---|
static int |
DIRECT_BYTE_BUFFER |
static int |
HEAP_BYTE_BUFFER |
static int |
MEMORY_MAPPED_FILE |
static String |
UNMAP_NOT_SUPPORTED_REASON
if
UNMAP_SUPPORTED is false, this contains the reason why unmapping is not supported. |
static boolean |
UNMAP_SUPPORTED
true, if this platform supports unmapping mmapped files. |
| Constructor and Description |
|---|
MatFileReader() |
MatFileReader(File file)
Creates instance of
MatFileReader and reads MAT-file
from file. |
MatFileReader(File file,
MatFileFilter filter)
Creates instance of
MatFileReader and reads MAT-file from
file. |
MatFileReader(String fileName)
Creates instance of
MatFileReader and reads MAT-file
from location given as fileName. |
MatFileReader(String fileName,
MatFileFilter filter)
Creates instance of
MatFileReader and reads MAT-file
from location given as fileName. |
| Modifier and Type | Method and Description |
|---|---|
Map<String,MLArray> |
getContent()
Returns a map of
MLArray objects that were inside MAT-file. |
ArrayList<MLArray> |
getData()
Deprecated.
use
getContent which returns a Map to provide
easier access to MLArrays contained in MAT-file |
MatFileHeader |
getMatFileHeader()
Gets MAT-file header
|
MLArray |
getMLArray(String name)
Returns the value to which the red file maps the specified array name.
|
Map<String,MLArray> |
read(File file)
Reads the content of a MAT-file and returns the mapped content.
|
Map<String,MLArray> |
read(File file,
int policy)
Reads the content of a MAT-file and returns the mapped content.
|
Map<String,MLArray> |
read(File file,
MatFileFilter filter,
int policy)
Reads the content of a MAT-file and returns the mapped content.
|
static void |
setAllowObjectDeserialization(boolean allowDeserialization)
Java objects can be stored in an MAT file.
|
public static final boolean UNMAP_SUPPORTED
true, if this platform supports unmapping mmapped files.public static final String UNMAP_NOT_SUPPORTED_REASON
UNMAP_SUPPORTED is false, this contains the reason why unmapping is not supported.public static final int MEMORY_MAPPED_FILE
public static final int DIRECT_BYTE_BUFFER
public static final int HEAP_BYTE_BUFFER
public MatFileReader(String fileName) throws IOException
MatFileReader and reads MAT-file
from location given as fileName.
This method reads MAT-file without filtering.fileName - the MAT-file path StringIOException - when error occurred while processing the file.public MatFileReader(String fileName, MatFileFilter filter) throws IOException
MatFileReader and reads MAT-file
from location given as fileName.
Results are filtered by MatFileFilter. Arrays that do not meet
filter match condition will not be available in results.fileName - the MAT-file path Stringfilter - array name filter.IOException - when error occurred while processing the file.public MatFileReader(File file) throws IOException
MatFileReader and reads MAT-file
from file.
This method reads MAT-file without filtering.file - the MAT-fileIOException - when error occurred while processing the file.public MatFileReader(File file, MatFileFilter filter) throws IOException
MatFileReader and reads MAT-file from
file.
Results are filtered by MatFileFilter. Arrays that do not
meet filter match condition will not be available in results.
Note: this method reads file using the memory mapped file policy, see
notes to read(File, MatFileFilter, int)
file - the MAT-filefilter - array name filter.IOException - when error occurred while processing the file.public MatFileReader()
public static void setAllowObjectDeserialization(boolean allowDeserialization)
false.
See: owasp's descriptionallowDeserialization - whether or not to allow deserialization of Java objectspublic Map<String,MLArray> read(File file) throws IOException
This method calls
read(file, new MatFileFilter(), MallocPolicy.MEMORY_MAPPED_FILE).
file - a valid MAT-file file to be readgetContent()IOException - if error occurs during file processingpublic Map<String,MLArray> read(File file, int policy) throws IOException
This method calls
read(file, new MatFileFilter(), policy).
file - a valid MAT-file file to be readpolicy - the file memory allocation policygetContent()IOException - if error occurs during file processingpublic Map<String,MLArray> read(File file, MatFileFilter filter, int policy) throws IOException
Because of java bug #4724038 which disables releasing the memory mapped resource, additional different allocation modes are available.
MEMORY_MAPPED_FILE - a memory mapped fileDIRECT_BYTE_BUFFER - a uses
ByteBuffer.allocateDirect(int) method to read in
the file contentsHEAP_BYTE_BUFFER - a uses
ByteBuffer.allocate(int) method to read in the
file contentsfile - a valid MAT-file file to be readfilter - the array filter applied during readingpolicy - the file memory allocation policygetContent()IOException - if error occurs during file processingMatFileFilterpublic MatFileHeader getMatFileHeader()
MatFileHeader objectpublic ArrayList<MLArray> getData()
getContent which returns a Map to provide
easier access to MLArrays contained in MAT-fileMLArray objects that were inside MAT-fileArrayListpublic MLArray getMLArray(String name)
null if the file contains no content for this name.name - - array nameMLArray to which this file maps the specified name,
or null if the file contains no content for this name.Copyright © 2018. All rights reserved.