public class MatFileIncrementalWriter extends Object
//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 and Description |
---|
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..
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
write(Collection<MLArray> data)
Writes
MLArrays into WritableByteChannel . |
void |
write(MLArray data) |
public MatFileIncrementalWriter(String fileName) throws IOException
fileName
- - name of ouput fileIOException
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
elementsIOException
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
objectsIOException
- if writing failspublic void close() throws IOException
IOException
Copyright © 2015. All rights reserved.