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 - on underlying IOExceptionpublic MatFileIncrementalWriter(File file) throws IOException
file - - an output FileIOException - on underlying IOExceptionpublic MatFileIncrementalWriter(WritableByteChannel chan) throws IOException
miCOMPRESSED).chan - - WritableByteChannelIOException - on underlying IOExceptionpublic void write(MLArray data) throws IOException
IOExceptionpublic void write(Collection<MLArray> data) throws IOException
MLArrays into WritableByteChannel.data - the collection of MLArray objectsIOException - if writing failspublic void close()
throws IOException
IOExceptionCopyright © 2016. All rights reserved.