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

Binary data reader. More...

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

Public Member Functions

 BinaryDataReader (String filename) throws IOException
 Opens the file with the specified name for reading. More...
 
 BinaryDataReader (URL url) throws IOException
 Opens the file at the specified url for reading. More...
 
 BinaryDataReader (File file) throws IOException
 Opens the specified file for reading. More...
 
 BinaryDataReader (InputStream inputStream) throws IOException
 Opens the specified input stream for reading. More...
 
Reading fields of unknown type
DataField readNextField () throws IOException
 Reads the next available field. More...
 
DataField readField (String label) throws IOException
 Reads the first field labeled as label. More...
 
Other methods
void reset () throws IOException
 Reopens the file (does not work with the constructor that takes an input stream).
 
boolean dataPending () throws IOException
 Returns true if there remains data to be read.
 
void close () throws IOException
 Closes the file.
 
- Public Member Functions inherited from AbstractDataReader
String readString (String label) throws IOException
 Reads first field labeled as label and returns its String value.
 
int readInt (String label) throws IOException
 Reads first field labeled as label and returns its int value.
 
float readFloat (String label) throws IOException
 Reads first field labeled as label and returns its float value.
 
double readDouble (String label) throws IOException
 Reads first field labeled as label and returns its double value.
 
String [] readStringArray (String label) throws IOException
 Reads first field labeled as label and returns its value as a one-dimensional array of String’s.
 
int [] readIntArray (String label) throws IOException
 Reads first field labeled as label and returns its value as a one-dimensional array of int’s.
 
float [] readFloatArray (String label) throws IOException
 Reads first field labeled as label and returns its value as a one-dimensional array of float’s.
 
double [] readDoubleArray (String label) throws IOException
 Reads first field labeled as label and returns its value as a one-dimensional array of double’s.
 
String [][] readStringArray2D (String label) throws IOException
 Reads first field labeled as label and returns its value as a two-dimensional array of String’s.
 
int [][] readIntArray2D (String label) throws IOException
 Reads first field labeled as label and returns its value as a two-dimensional array of int’s.
 
float [][] readFloatArray2D (String label) throws IOException
 Reads first field labeled as label and returns its value as a two-dimensional array of float’s.
 
double [][] readDoubleArray2D (String label) throws IOException
 Reads first field labeled as label and returns its value as a two-dimensional array of double’s.
 
Map< String, DataFieldreadAllNextFields () throws IOException
 Reads all remaining fields in the file and returns a hashmap indexed by field labels. More...
 
Map< String, DataFieldreadAllFields () throws IOException
 Reads all fields in the file and returns a hashmap indexed by field labels. More...
 
Reading atomic data
Reading one-dimensional arrays
Reading two-dimensional arrays
Reading fields of unknown type
Other methods

Protected Member Functions

String readLabel () throws IOException
 Reads current field label.
 
String readStringData () throws IOException
 Reads string data.
 
String [] readStringArrayData (int dim) throws IOException
 Reads string-array data.
 
String [][] readStringArray2DData (int dims[]) throws IOException
 Reads 2D string-array data.
 
int readIntData () throws IOException
 Reads integer data.
 
int [] readIntArrayData (int dim) throws IOException
 Reads integer-array data.
 
int [][] readIntArray2DData (int dims[]) throws IOException
 Reads 2D integer-array data.
 
float readFloatData () throws IOException
 Reads float data.
 
float [] readFloatArrayData (int dim) throws IOException
 Reads float-array data.
 
float [][] readFloatArray2DData (int dims[]) throws IOException
 Reads 2D float-array data.
 
double readDoubleData () throws IOException
 Reads double data.
 
double [] readDoubleArrayData (int dim) throws IOException
 Reads double-array data.
 
double [][] readDoubleArray2DData (int dims[]) throws IOException
 Reads 2D double-array data.
 
Object readFieldData (byte typechar, int nDims, int dims[]) throws IOException
 Reads field data of arbitrary type. More...
 

Protected Attributes

DataInputStream in
 
String filename = null
 
URL url = null
 
File file = null
 
boolean canReset = false
 

Detailed Description

Binary data reader.

This class implements a module for importing data written with BinaryDataWriter.

Constructor & Destructor Documentation

◆ BinaryDataReader() [1/4]

BinaryDataReader ( String  filename) throws IOException

Opens the file with the specified name for reading.

Parameters
filenamename of the file to read the data from

◆ BinaryDataReader() [2/4]

BinaryDataReader ( URL  url) throws IOException

Opens the file at the specified url for reading.

Parameters
urlurl of the file to read the data from

◆ BinaryDataReader() [3/4]

BinaryDataReader ( File  file) throws IOException

Opens the specified file for reading.

Parameters
filefile to read the data from

◆ BinaryDataReader() [4/4]

BinaryDataReader ( InputStream  inputStream) throws IOException

Opens the specified input stream for reading.

When using this constructor, the method readField might will not be able to read a field that is before the current reading position.

Parameters
inputStreaminput stream to read the data from

Member Function Documentation

◆ readField()

DataField readField ( String  label) throws IOException

Reads the first field labeled as label.

Returns
a newly created DataField instance or null if not found

Implements DataReader.

◆ readFieldData()

Object readFieldData ( byte  typechar,
int  nDims,
int  dims[] 
) throws IOException
protected

Reads field data of arbitrary type.

Parameters
typechartype code character (see BinaryDataWriter constants)
nDimsnumber of dimensions (0 for atomic data)
dimslength of each dimension
Returns
an instance of the data or
null
if data type is unknown

◆ readNextField()

DataField readNextField ( ) throws IOException

Reads the next available field.

Returns
a newly created DataField instance or null if not found

Implements DataReader.


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