ch.javasoft.jsmat
Class MatFileWriter

java.lang.Object
  extended by ch.javasoft.jsmat.MatWriter<RandomAccessFile>
      extended by ch.javasoft.jsmat.MatFileWriter

public class MatFileWriter
extends MatWriter<RandomAccessFile>

The MatFileWriter writes a .mat file.

This class is a memory efficient version of MatOutputStreamWriter optimized for file targets. A RandomAccessFile is used to write the file.


Field Summary
 
Fields inherited from class ch.javasoft.jsmat.MatWriter
mReservedWriter
 
Constructor Summary
MatFileWriter(File file)
          Constructor to write to the given file
MatFileWriter(RandomAccessFile file)
          Constructor to write to the given ras file
 
Method Summary
 void close()
          Closes the underlying file
protected  VariableWriter createVariableWriter()
          Creates a writer for variable output.
protected  void initDataOutput(RandomAccessFile ras)
          The file is cleared, that is, RandomAccessFile.setLength(long) is called.
 
Methods inherited from class ch.javasoft.jsmat.MatWriter
checkNoReservedWriter, createReservedWriter, createReservedWriter, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatFileWriter

public MatFileWriter(File file)
              throws IOException
Constructor to write to the given file

Parameters:
file - the file to create
Throws:
IOException - if any io exception occurs

MatFileWriter

public MatFileWriter(RandomAccessFile file)
              throws IOException
Constructor to write to the given ras file

Parameters:
file - the ras file to create
Throws:
IOException - if any io exception occurs
Method Detail

initDataOutput

protected void initDataOutput(RandomAccessFile ras)
                       throws IOException
The file is cleared, that is, RandomAccessFile.setLength(long) is called.

Specified by:
initDataOutput in class MatWriter<RandomAccessFile>
Parameters:
ras - the data output object to initialize
Throws:
IOException

createVariableWriter

protected VariableWriter createVariableWriter()
                                       throws IOException
Description copied from class: MatWriter
Creates a writer for variable output. Variables are written compressed, which needs some initialization executed when VariableWriter.open() is called. The same structures must be released again after writing the variable data, which is done in VariableWriter.close().

Specified by:
createVariableWriter in class MatWriter<RandomAccessFile>
Throws:
IOException

close

public void close()
           throws IOException
Closes the underlying file

Specified by:
close in class MatWriter<RandomAccessFile>
Throws:
IOException - if any io exception occurs