SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BinaryDataWriter Class Reference

Binary data writer. More...

Inheritance diagram for BinaryDataWriter:
[legend]
Collaboration diagram for BinaryDataWriter:
[legend]

Public Member Functions

 BinaryDataWriter (String filename, boolean append) throws IOException
 Data will be output to the file with the specified name. More...
 
 BinaryDataWriter (File file, boolean append) throws IOException
 Data will be output to the specified file. More...
 
 BinaryDataWriter (String filename) throws IOException
 Truncates any existing file with the specified name. More...
 
 BinaryDataWriter (File file) throws IOException
 Truncates any existing file with the specified name. More...
 
 BinaryDataWriter (OutputStream outputStream) throws IOException
 Constructor. More...
 
Writing atomic data
void write (String label, String s) throws IOException
 Writes an atomic string field. More...
 
void write (String label, int a) throws IOException
 Writes an atomic 32-bit integer (big endian). More...
 
void write (String label, float a) throws IOException
 Writes an atomic 32-bit float (big endian). More...
 
void write (String label, double a) throws IOException
 Writes an atomic 64-bit double (big endian). More...
 
Writing one-dimensional arrays
void write (String label, String[] a, int n) throws IOException
 Writes the first n elements of a one-dimensional array of strings. More...
 
void write (String label, int[] a, int n) throws IOException
 Writes the first n elements of a one-dimensional array of 32-bit integers (big endian). More...
 
void write (String label, float[] a, int n) throws IOException
 Writes the first n elements of a one-dimensional array of 32-bit floats (big endian). More...
 
void write (String label, double[] a, int n) throws IOException
 Writes the first n elements of a one-dimensional array of 64-bit doubles (big endian). More...
 
Writing two-dimensional arrays
void write (String label, String[][] a) throws IOException
 Writes a two-dimensional array of strings. More...
 
void write (String label, int[][] a) throws IOException
 Writes a two-dimensional array of 32-bit integers (big endian). More...
 
void write (String label, float[][] a) throws IOException
 Writes a two-dimensional array of 32-bit floats (big endian). More...
 
void write (String label, double[][] a) throws IOException
 Writes a two-dimensional array of 64-bit doubles (big endian). More...
 
Other methods
void close () throws IOException
 Flushes any pending data and closes the file.
 
- Public Member Functions inherited from AbstractDataWriter
void write (String label, String[] a) throws IOException
 Writes a one-dimensional array of strings. More...
 
void write (String label, int[] a) throws IOException
 Writes a one-dimensional array of 32-bit integers (big endian). More...
 
void write (String label, float[] a) throws IOException
 Writes a one-dimensional array of 32-bit floats (big endian). More...
 
void write (String label, double[] a) throws IOException
 Writes a one-dimensional array of 64-bit doubles (big endian). More...
 
Writing atomic data
Writing one-dimensional arrays
Writing two-dimensional arrays
Other methods

Static Public Attributes

Fields
static final byte TYPECHAR_LABEL = '|'
 Field-type symbol indicating a label (it more accurately a field separator symbol).
 
static final byte TYPECHAR_STRING = 'S'
 Field-type symbol indicating String data.
 
static final byte TYPECHAR_INTEGER = 'i'
 Field-type symbol indicating int data.
 
static final byte TYPECHAR_FLOAT = 'f'
 Field-type symbol indicating float data.
 
static final byte TYPECHAR_DOUBLE = 'd'
 Field-type symbol indicating double data.
 

Protected Member Functions

void writeStringData (String s) throws IOException
 Utility method to write string data.
 
void writeLabel (String label) throws IOException
 Starts a new field by writing its label. More...
 

Protected Attributes

DataOutputStream out
 

Detailed Description

Binary data writer.

Stores a sequence of fields in binary file, which can be either atoms or arrays, each of which having the following format:

In the case of an atomic field, the number of dimensions is set to zero.

A string field is stored in the following format:

Also supports anonymous fields (fields with an empty label).

Arrays up to two dimensions are supported.

Modules for reading data exported with this class are available in Java ( BinaryDataReader ), Matlab and Python (numpy).

Provide links for the import modules.

Constructor & Destructor Documentation

◆ BinaryDataWriter() [1/5]

BinaryDataWriter ( String  filename,
boolean  append 
) throws IOException

Data will be output to the file with the specified name.

Parameters
filenamename of the file to be created or appended to
appendan existing file with the specified name will be appended to if true or truncated if false

◆ BinaryDataWriter() [2/5]

BinaryDataWriter ( File  file,
boolean  append 
) throws IOException

Data will be output to the specified file.

Parameters
filefile to be created or appended to
appendan existing file with the specified name will be appended to if true or truncated if false

◆ BinaryDataWriter() [3/5]

BinaryDataWriter ( String  filename) throws IOException

Truncates any existing file with the specified name.

Parameters
filenamename of the file to be created

◆ BinaryDataWriter() [4/5]

BinaryDataWriter ( File  file) throws IOException

Truncates any existing file with the specified name.

Parameters
filefile to be created

◆ BinaryDataWriter() [5/5]

BinaryDataWriter ( OutputStream  outputStream) throws IOException

Constructor.

Parameters
outputStreamoutput stream to write to

Member Function Documentation

◆ write() [1/12]

void write ( String  label,
String  s 
) throws IOException

Writes an atomic string field.

Writes an anonymous field if label is null.

Implements DataWriter.

◆ write() [2/12]

void write ( String  label,
int  a 
) throws IOException

Writes an atomic 32-bit integer (big endian).

Writes an anonymous field if label is null.

Implements DataWriter.

◆ write() [3/12]

void write ( String  label,
float  a 
) throws IOException

Writes an atomic 32-bit float (big endian).

Writes an anonymous field if label is null.

Implements DataWriter.

◆ write() [4/12]

void write ( String  label,
double  a 
) throws IOException

Writes an atomic 64-bit double (big endian).

Writes an anonymous field if label is null.

Implements DataWriter.

◆ write() [5/12]

void write ( String  label,
String []  a,
int  n 
) throws IOException

Writes the first n elements of a one-dimensional array of strings.

Writes an anonymous field if label is null.

Implements DataWriter.

◆ write() [6/12]

void write ( String  label,
int []  a,
int  n 
) throws IOException

Writes the first n elements of a one-dimensional array of 32-bit integers (big endian).

Writes an anonymous field if label is null.

Implements DataWriter.

◆ write() [7/12]

void write ( String  label,
float []  a,
int  n 
) throws IOException

Writes the first n elements of a one-dimensional array of 32-bit floats (big endian).

Writes an anonymous field if label is null.

Implements DataWriter.

◆ write() [8/12]

void write ( String  label,
double []  a,
int  n 
) throws IOException

Writes the first n elements of a one-dimensional array of 64-bit doubles (big endian).

Writes an anonymous field if label is null.

Implements DataWriter.

◆ write() [9/12]

void write ( String  label,
String  a[][] 
) throws IOException

Writes a two-dimensional array of strings.

Writes an anonymous field if label is null.

Implements DataWriter.

◆ write() [10/12]

void write ( String  label,
int  a[][] 
) throws IOException

Writes a two-dimensional array of 32-bit integers (big endian).

Writes an anonymous field if label is null.

Implements DataWriter.

◆ write() [11/12]

void write ( String  label,
float  a[][] 
) throws IOException

Writes a two-dimensional array of 32-bit floats (big endian).

Writes an anonymous field if label is null.

Implements DataWriter.

◆ write() [12/12]

void write ( String  label,
double  a[][] 
) throws IOException

Writes a two-dimensional array of 64-bit doubles (big endian).

Writes an anonymous field if label is null.

Implements DataWriter.

◆ writeLabel()

void writeLabel ( String  label) throws IOException
protected

Starts a new field by writing its label.

Parameters
labelname of the field (can be
null
)

The documentation for this class was generated from the following file: