SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.util.io.TextDataWriter Class Reference

Text data writer. More...

Inheritance diagram for umontreal.ssj.util.io.TextDataWriter:
umontreal.ssj.util.io.CachedDataWriter umontreal.ssj.util.io.AbstractDataWriter umontreal.ssj.util.io.DataWriter

Classes

enum  Format
 Output format: organize fields as columns or as rows. More...

Public Member Functions

 TextDataWriter (String filename, Format format, boolean withHeaders) throws IOException
 Class constructor.
 TextDataWriter (File file, Format format, boolean withHeaders) throws IOException
 Class constructor.
 TextDataWriter (OutputStream outputStream, Format format, boolean withHeaders) throws IOException
 Class constructor.
void setFormat (Format format)
 Changes the output format.
void setFloatFormatString (String formatString)
 Sets the format string used to output floating point numbers.
void setColumnSeparator (String columnSeparator)
 Changes the column separator.
void setHeaderPrefix (String headerPrefix)
 Changes the header prefix (a string that indicates the beginning of the header line for the COLUMNS format).
void close () throws IOException
 Flushes any pending data and closes the file or stream.
Public Member Functions inherited from umontreal.ssj.util.io.CachedDataWriter
 CachedDataWriter ()
 Class constructor.
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).
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).
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).
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

Fields @{

final String DEFAULT_COLUMN_SEPARATOR = "\t"
 Default value for the column separator.
final String DEFAULT_HEADER_PREFIX = ""
 Default value for the header prefix.
int getMaxFieldLength ()
 Returns the maximum field length.
void outputAsColumns () throws IOException
 Outputs fields as columns.
void outputAsRows () throws IOException
 Outputs fields as rows.
void writeFormat (Object o) throws IOException
 Formats the object in accordance with the current format strings settings.

Detailed Description

Text data writer.

Writes fields as columns or as rows in a text file.

Definition at line 35 of file TextDataWriter.java.

Constructor & Destructor Documentation

◆ TextDataWriter() [1/3]

umontreal.ssj.util.io.TextDataWriter.TextDataWriter ( String filename,
Format format,
boolean withHeaders ) throws IOException

Class constructor.

Truncates any existing file with the specified name.

Parameters
filenamename of the file to write to
formatorganize fields as columns if set to COLUMNS or as rows if set to ROWS
withHeadersoutput headers or not

Definition at line 206 of file TextDataWriter.java.

◆ TextDataWriter() [2/3]

umontreal.ssj.util.io.TextDataWriter.TextDataWriter ( File file,
Format format,
boolean withHeaders ) throws IOException

Class constructor.

Truncates any conflicting file.

Parameters
filefile to write to
formatorganize fields as columns if set to COLUMNS or as rows if set to ROWS
withHeadersoutput headers or not

Definition at line 220 of file TextDataWriter.java.

◆ TextDataWriter() [3/3]

umontreal.ssj.util.io.TextDataWriter.TextDataWriter ( OutputStream outputStream,
Format format,
boolean withHeaders ) throws IOException

Class constructor.

Parameters
outputStreamoutput stream to write to
formatorganize fields as columns if set to COLUMNS or as rows if set to ROWS
withHeadersoutput headers or not

Definition at line 234 of file TextDataWriter.java.

Member Function Documentation

◆ close()

void umontreal.ssj.util.io.TextDataWriter.close ( ) throws IOException

Flushes any pending data and closes the file or stream.

Implements umontreal.ssj.util.io.DataWriter.

Definition at line 277 of file TextDataWriter.java.

◆ getMaxFieldLength()

int umontreal.ssj.util.io.TextDataWriter.getMaxFieldLength ( )
protected

Returns the maximum field length.

Definition at line 65 of file TextDataWriter.java.

◆ outputAsColumns()

void umontreal.ssj.util.io.TextDataWriter.outputAsColumns ( ) throws IOException
protected

Outputs fields as columns.

Definition at line 78 of file TextDataWriter.java.

◆ outputAsRows()

void umontreal.ssj.util.io.TextDataWriter.outputAsRows ( ) throws IOException
protected

Outputs fields as rows.

Definition at line 133 of file TextDataWriter.java.

◆ setColumnSeparator()

void umontreal.ssj.util.io.TextDataWriter.setColumnSeparator ( String columnSeparator)

Changes the column separator.

Definition at line 262 of file TextDataWriter.java.

◆ setFloatFormatString()

void umontreal.ssj.util.io.TextDataWriter.setFloatFormatString ( String formatString)

Sets the format string used to output floating point numbers.

Parameters
formatStringformat string (e.g., %.4g)

Definition at line 255 of file TextDataWriter.java.

◆ setFormat()

void umontreal.ssj.util.io.TextDataWriter.setFormat ( Format format)

Changes the output format.

Parameters
formatorganize fields as columns if set to COLUMNS or as rows if set to ROWS

Definition at line 246 of file TextDataWriter.java.

◆ setHeaderPrefix()

void umontreal.ssj.util.io.TextDataWriter.setHeaderPrefix ( String headerPrefix)

Changes the header prefix (a string that indicates the beginning of the header line for the COLUMNS format).

Definition at line 270 of file TextDataWriter.java.

◆ writeFormat()

void umontreal.ssj.util.io.TextDataWriter.writeFormat ( Object o) throws IOException
protected

Formats the object in accordance with the current format strings settings.

Definition at line 178 of file TextDataWriter.java.

Member Data Documentation

◆ DEFAULT_COLUMN_SEPARATOR

final String umontreal.ssj.util.io.TextDataWriter.DEFAULT_COLUMN_SEPARATOR = "\t"

Default value for the column separator.

Definition at line 44 of file TextDataWriter.java.

◆ DEFAULT_HEADER_PREFIX

final String umontreal.ssj.util.io.TextDataWriter.DEFAULT_HEADER_PREFIX = ""

Default value for the header prefix.

Definition at line 49 of file TextDataWriter.java.


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