Binary data writer. More...
Public Member Functions | |
| BinaryDataWriter (String filename, boolean append) throws IOException | |
| Data will be output to the file with the specified name. | |
| BinaryDataWriter (File file, boolean append) throws IOException | |
| Data will be output to the specified file. | |
| BinaryDataWriter (String filename) throws IOException | |
| Truncates any existing file with the specified name. | |
| BinaryDataWriter (File file) throws IOException | |
| Truncates any existing file with the specified name. | |
| BinaryDataWriter (OutputStream outputStream) throws IOException | |
| Constructor. | |
Writing atomic data @{ | |
| void | write (String label, String s) throws IOException |
| Writes an atomic string field. | |
| void | write (String label, int a) throws IOException |
| Writes an atomic 32-bit integer (big endian). | |
| void | write (String label, float a) throws IOException |
| Writes an atomic 32-bit float (big endian). | |
| void | write (String label, double a) throws IOException |
| Writes an atomic 64-bit double (big endian). | |
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. | |
| 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). | |
| 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). | |
| 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). | |
Writing two-dimensional arrays @{ | |
| void | write (String label, String[][] a) throws IOException |
| Writes a two-dimensional array of strings. | |
| void | write (String label, int[][] a) throws IOException |
| Writes a two-dimensional array of 32-bit integers (big endian). | |
| void | write (String label, float[][] a) throws IOException |
| Writes a two-dimensional array of 32-bit floats (big endian). | |
| void | write (String label, double[][] a) throws IOException |
| Writes a two-dimensional array of 64-bit doubles (big endian). | |
Other methods @{ | |
| void | close () throws IOException |
| Flushes any pending data and closes the file. | |
| Public Member Functions inherited from umontreal.ssj.util.io.AbstractDataWriter | |
| void | write (String label, String[] a) throws IOException |
| Writes a one-dimensional array of strings. | |
| void | write (String label, int[] a) throws IOException |
| Writes a one-dimensional array of 32-bit integers (big endian). | |
| void | write (String label, float[] a) throws IOException |
| Writes a one-dimensional array of 32-bit floats (big endian). | |
| void | write (String label, double[] a) throws IOException |
| Writes a one-dimensional array of 64-bit doubles (big endian). | |
| Public Member Functions inherited from umontreal.ssj.util.io.DataWriter | |
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. | |
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:
Field label:
Field type (byte):
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. <div class="SSJ-bigskip"></div>
Definition at line 79 of file BinaryDataWriter.java.
| umontreal.ssj.util.io.BinaryDataWriter.BinaryDataWriter | ( | String | filename, |
| boolean | append ) throws IOException |
Data will be output to the file with the specified name.
| filename | name of the file to be created or appended to |
| append | an existing file with the specified name will be appended to if true or truncated if false |
Definition at line 147 of file BinaryDataWriter.java.
| umontreal.ssj.util.io.BinaryDataWriter.BinaryDataWriter | ( | File | file, |
| boolean | append ) throws IOException |
Data will be output to the specified file.
| file | file to be created or appended to |
| append | an existing file with the specified name will be appended to if true or truncated if false |
Definition at line 158 of file BinaryDataWriter.java.
| umontreal.ssj.util.io.BinaryDataWriter.BinaryDataWriter | ( | String | filename | ) | throws IOException |
Truncates any existing file with the specified name.
| filename | name of the file to be created |
Definition at line 167 of file BinaryDataWriter.java.
| umontreal.ssj.util.io.BinaryDataWriter.BinaryDataWriter | ( | File | file | ) | throws IOException |
Truncates any existing file with the specified name.
| file | file to be created |
Definition at line 176 of file BinaryDataWriter.java.
| umontreal.ssj.util.io.BinaryDataWriter.BinaryDataWriter | ( | OutputStream | outputStream | ) | throws IOException |
Constructor.
| outputStream | output stream to write to |
Definition at line 185 of file BinaryDataWriter.java.
| void umontreal.ssj.util.io.BinaryDataWriter.close | ( | ) | throws IOException |
Flushes any pending data and closes the file.
Implements umontreal.ssj.util.io.DataWriter.
Definition at line 376 of file BinaryDataWriter.java.
| void umontreal.ssj.util.io.BinaryDataWriter.write | ( | String | label, |
| double | a ) throws IOException |
Writes an atomic 64-bit double (big endian).
Writes an anonymous field if label is null.
Implements umontreal.ssj.util.io.DataWriter.
Definition at line 230 of file BinaryDataWriter.java.
| void umontreal.ssj.util.io.BinaryDataWriter.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 umontreal.ssj.util.io.DataWriter.
Definition at line 288 of file BinaryDataWriter.java.
| void umontreal.ssj.util.io.BinaryDataWriter.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 umontreal.ssj.util.io.DataWriter.
Definition at line 354 of file BinaryDataWriter.java.
| void umontreal.ssj.util.io.BinaryDataWriter.write | ( | String | label, |
| float | a ) throws IOException |
Writes an atomic 32-bit float (big endian).
Writes an anonymous field if label is null.
Implements umontreal.ssj.util.io.DataWriter.
Definition at line 219 of file BinaryDataWriter.java.
| void umontreal.ssj.util.io.BinaryDataWriter.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 umontreal.ssj.util.io.DataWriter.
Definition at line 275 of file BinaryDataWriter.java.
| void umontreal.ssj.util.io.BinaryDataWriter.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 umontreal.ssj.util.io.DataWriter.
Definition at line 339 of file BinaryDataWriter.java.
| void umontreal.ssj.util.io.BinaryDataWriter.write | ( | String | label, |
| int | a ) throws IOException |
Writes an atomic 32-bit integer (big endian).
Writes an anonymous field if label is null.
Implements umontreal.ssj.util.io.DataWriter.
Definition at line 208 of file BinaryDataWriter.java.
| void umontreal.ssj.util.io.BinaryDataWriter.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 umontreal.ssj.util.io.DataWriter.
Definition at line 262 of file BinaryDataWriter.java.
| void umontreal.ssj.util.io.BinaryDataWriter.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 umontreal.ssj.util.io.DataWriter.
Definition at line 324 of file BinaryDataWriter.java.
| void umontreal.ssj.util.io.BinaryDataWriter.write | ( | String | label, |
| String | s ) throws IOException |
Writes an atomic string field.
Writes an anonymous field if label is null.
Implements umontreal.ssj.util.io.DataWriter.
Definition at line 197 of file BinaryDataWriter.java.
| void umontreal.ssj.util.io.BinaryDataWriter.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 umontreal.ssj.util.io.DataWriter.
Definition at line 249 of file BinaryDataWriter.java.
| void umontreal.ssj.util.io.BinaryDataWriter.write | ( | String | label, |
| String | a[][] ) throws IOException |
Writes a two-dimensional array of strings.
Writes an anonymous field if label is null.
Implements umontreal.ssj.util.io.DataWriter.
Definition at line 309 of file BinaryDataWriter.java.
|
protected |
Starts a new field by writing its label.
| label | name of the field (can be null) |
Definition at line 101 of file BinaryDataWriter.java.
|
protected |
Utility method to write string data.
Definition at line 86 of file BinaryDataWriter.java.
|
static |
Field-type symbol indicating double data.
Definition at line 134 of file BinaryDataWriter.java.
|
static |
Field-type symbol indicating float data.
Definition at line 129 of file BinaryDataWriter.java.
|
static |
Field-type symbol indicating int data.
Definition at line 124 of file BinaryDataWriter.java.
|
static |
Field-type symbol indicating a label (it more accurately a field separator symbol).
Definition at line 114 of file BinaryDataWriter.java.
|
static |
Field-type symbol indicating String data.
Definition at line 119 of file BinaryDataWriter.java.