com.jmatio.io
Class MatFileWriter

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

public class MatFileWriter
extends Object

MAT-file writer. 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
 ArrayList list = new ArrayList();
 list.add( mlDouble );
 list.add( mlChar );
 
 new MatFileWriter( "mat_file.mat", list );
 
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', 'char_arr');
 

Author:
Wojciech Gradkowski (wgradkowski@gmail.com)

Constructor Summary
MatFileWriter()
          Creates the new MatFileWriter instance
MatFileWriter(File file, Collection<MLArray> data)
          Writes MLArrays into File.
MatFileWriter(String fileName, Collection<MLArray> data)
          Writes MLArrays into file given by fileName.
MatFileWriter(WritableByteChannel channel, Collection<MLArray> data)
          Writes MLArrays into OuputSteram.
 
Method Summary
 void write(File file, Collection<MLArray> data)
          Writes MLArrays into File
 void write(String filepath, Collection<MLArray> data)
          Writes MLArrays into file created from filepath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatFileWriter

public MatFileWriter()
Creates the new MatFileWriter instance


MatFileWriter

public MatFileWriter(String fileName,
                     Collection<MLArray> data)
              throws IOException
Writes MLArrays into file given by fileName.

Parameters:
fileName - - name of ouput file
data - - Collection of MLArray elements
Throws:
IOException
DataFormatException

MatFileWriter

public MatFileWriter(File file,
                     Collection<MLArray> data)
              throws IOException
Writes MLArrays into File.

Parameters:
file - - an output File
data - - Collection of MLArray elements
Throws:
IOException
DataFormatException

MatFileWriter

public MatFileWriter(WritableByteChannel channel,
                     Collection<MLArray> data)
              throws IOException
Writes MLArrays into OuputSteram. Writes MAT-file header and compressed data (miCOMPRESSED).

Parameters:
output - - OutputStream
data - - Collection of MLArray elements
Throws:
IOException
Method Detail

write

public void write(String filepath,
                  Collection<MLArray> data)
           throws IOException
Writes MLArrays into file created from filepath.

Parameters:
filepath - the absolute file path of a MAT-file to which data is written
data - the collection of MLArray objects
Throws:
IOException - if error occurred during MAT-file writing

write

public void write(File file,
                  Collection<MLArray> data)
           throws IOException
Writes MLArrays into File

Parameters:
file - the MAT-file to which data is written
data - the collection of MLArray objects
Throws:
IOException - if error occurred during MAT-file writing


Copyright © 2006–2014 GeoSolutions. All rights reserved.