com.jmatio.io
Class MatFileIncrementalWriter

java.lang.Object
  extended by com.jmatio.io.MatFileIncrementalWriter

public class MatFileIncrementalWriter
extends Object

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');
 

Author:

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

MatFileIncrementalWriter

public MatFileIncrementalWriter(String fileName)
                         throws IOException
Creates a writer to a file given the filename.

Parameters:
fileName - - name of ouput file
Throws:
IOException
DataFormatException

MatFileIncrementalWriter

public MatFileIncrementalWriter(File file)
                         throws IOException
Creats a writer to a file given the File object.

Parameters:
file - - an output File
Throws:
IOException
DataFormatException

MatFileIncrementalWriter

public MatFileIncrementalWriter(WritableByteChannel chan)
                         throws IOException
Creates a writer for a file, given an output channel to the file.. Writes MAT-file header and compressed data (miCOMPRESSED).

Parameters:
chan - - WritableByteChannel
data - - Collection of MLArray elements
Throws:
IOException
Method Detail

write

public void write(MLArray data)
           throws IOException
Throws:
IOException

write

public void write(Collection<MLArray> data)
           throws IOException
Writes MLArrays into WritableByteChannel.

Parameters:
channel - the channel to write to
data - the collection of MLArray objects
Throws:
IOException - if writing fails

close

public void close()
           throws IOException
Throws:
IOException


Copyright © 2006–2013 GeoSolutions. All rights reserved.