|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jmatio.io.MatFileIncrementalWriter
public class MatFileIncrementalWriter
MAT-file Incremental writer. An updated writer which allows adding variables incrementally for the life of the writer. This is necessary to allow large variables to be written without having to hold onto then longer than is necessary. The writer internally maintains a list of the variable names it has written so far, and will throw an exception if the same variable name is submitted more than once to the same reader. Usage:
//1. First create example arrays
double[] src = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
MLDouble mlDouble = new MLDouble( "double_arr", src, 3 );
MLChar mlChar = new MLChar( "char_arr", "I am dummy" );
//2. write arrays to file
MatFileIncrementalWriter writer = new MatFileIncrementalWriter( new File("mat_file.mat"));
writer.write(mlDouble);
writer.write(mlChar);
writer.close();
this is "equal" to Matlab commands:
>> double_arr = [ 1 2; 3 4; 5 6];
>> char_arr = 'I am dummy';
>>
>> save('mat_file.mat', 'double_arr');
>> save('mat_file.mat', 'char_arr', '-append');
Constructor Summary | |
---|---|
MatFileIncrementalWriter(File file)
Creats a writer to a file given the File object. |
|
MatFileIncrementalWriter(String fileName)
Creates a writer to a file given the filename. |
|
MatFileIncrementalWriter(WritableByteChannel chan)
Creates a writer for a file, given an output channel to the file.. |
Method Summary | |
---|---|
void |
close()
|
void |
write(Collection<MLArray> data)
Writes MLArrays into WritableByteChannel . |
void |
write(MLArray data)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MatFileIncrementalWriter(String fileName) throws IOException
fileName
- - name of ouput file
IOException
DataFormatException
public MatFileIncrementalWriter(File file) throws IOException
file
- - an output File
IOException
DataFormatException
public MatFileIncrementalWriter(WritableByteChannel chan) throws IOException
miCOMPRESSED
).
chan
- - WritableByteChannel
data
- - Collection
of MLArray
elements
IOException
Method Detail |
---|
public void write(MLArray data) throws IOException
IOException
public void write(Collection<MLArray> data) throws IOException
MLArrays
into WritableByteChannel
.
channel
- the channel to write todata
- the collection of MLArray
objects
IOException
- if writing failspublic void close() throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |