public class MatFileIncrementalWriter
extends java.lang.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(java.io.File file)
Creats a writer to a file given the File object.
|
MatFileIncrementalWriter(java.lang.String fileName)
Creates a writer to a file given the filename.
|
MatFileIncrementalWriter(java.nio.channels.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(java.util.Collection<MLArray> data)
Writes
MLArrays into WritableByteChannel . |
void |
write(MLArray data) |
public MatFileIncrementalWriter(java.lang.String fileName) throws java.io.IOException
fileName
- - name of ouput filejava.io.IOException
java.util.zip.DataFormatException
public MatFileIncrementalWriter(java.io.File file) throws java.io.IOException
file
- - an output File
java.io.IOException
java.util.zip.DataFormatException
public MatFileIncrementalWriter(java.nio.channels.WritableByteChannel chan) throws java.io.IOException
miCOMPRESSED
).chan
- - WritableByteChannel
data
- - Collection
of MLArray
elementsjava.io.IOException
public void write(MLArray data) throws java.io.IOException
java.io.IOException
public void write(java.util.Collection<MLArray> data) throws java.io.IOException
MLArrays
into WritableByteChannel
.channel
- the channel to write todata
- the collection of MLArray
objectsjava.io.IOException
- if writing failspublic void close() throws java.io.IOException
java.io.IOException