SSJ
V. 2.6.

umontreal.iro.lecuyer.util.io
Class TextDataWriter

java.lang.Object
  extended by umontreal.iro.lecuyer.util.io.AbstractDataWriter
      extended by umontreal.iro.lecuyer.util.io.CachedDataWriter
          extended by umontreal.iro.lecuyer.util.io.TextDataWriter
All Implemented Interfaces:
DataWriter

public class TextDataWriter
extends CachedDataWriter

Text data writer. Writes fields as columns or as rows in a text file.


Nested Class Summary
static class TextDataWriter.Format
          Output format: organize fields as columns or as rows.
 
Field Summary
 String DEFAULT_COLUMN_SEPARATOR
          Default value for the column separator.
 String DEFAULT_HEADER_PREFIX
          Default value for the header prefix.
 
Constructor Summary
TextDataWriter(File file, TextDataWriter.Format format, boolean withHeaders)
          Class constructor.
TextDataWriter(OutputStream outputStream, TextDataWriter.Format format, boolean withHeaders)
          Class constructor.
TextDataWriter(String filename, TextDataWriter.Format format, boolean withHeaders)
          Class constructor.
 
Method Summary
 void close()
          Flushes any pending data and closes the file or stream.
 void setColumnSeparator(String columnSeparator)
          Changes the column separator.
 void setFloatFormatString(String formatString)
          Sets the format string used to output floating point numbers.
 void setFormat(TextDataWriter.Format format)
          Changes the output format.
 void setHeaderPrefix(String headerPrefix)
          Changes the header prefix (a string that indicates the beginning of the header line for the COLUMNS format).
 
Methods inherited from class umontreal.iro.lecuyer.util.io.CachedDataWriter
write, write, write, write, write, write, write, write, write, write, write, write
 
Methods inherited from class umontreal.iro.lecuyer.util.io.AbstractDataWriter
write, write, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_COLUMN_SEPARATOR

public final String DEFAULT_COLUMN_SEPARATOR
Default value for the column separator.

See Also:
Constant Field Values

DEFAULT_HEADER_PREFIX

public final String DEFAULT_HEADER_PREFIX
Default value for the header prefix.

See Also:
Constant Field Values
Constructor Detail

TextDataWriter

public TextDataWriter(String filename,
                      TextDataWriter.Format format,
                      boolean withHeaders)
               throws IOException
Class constructor. Truncates any existing file with the specified name.

Parameters:
filename - name of the file to write to
format - organize fields as columns if set to COLUMNS or as rows if set to ROWS
withHeaders - output headers or not
Throws:
IOException

TextDataWriter

public TextDataWriter(File file,
                      TextDataWriter.Format format,
                      boolean withHeaders)
               throws IOException
Class constructor. Truncates any conflicting file.

Parameters:
file - file to write to
format - organize fields as columns if set to COLUMNS or as rows if set to ROWS
withHeaders - output headers or not
Throws:
IOException

TextDataWriter

public TextDataWriter(OutputStream outputStream,
                      TextDataWriter.Format format,
                      boolean withHeaders)
               throws IOException
Class constructor.

Parameters:
outputStream - output stream to write to
format - organize fields as columns if set to COLUMNS or as rows if set to ROWS
withHeaders - output headers or not
Throws:
IOException
Method Detail

setFormat

public void setFormat(TextDataWriter.Format format)
Changes the output format.

Parameters:
format - organize fields as columns if set to COLUMNS or as rows if set to ROWS

setFloatFormatString

public void setFloatFormatString(String formatString)
Sets the format string used to output floating point numbers.

Parameters:
formatString - format string (e.g., %.4g)

setColumnSeparator

public void setColumnSeparator(String columnSeparator)
Changes the column separator.


setHeaderPrefix

public void setHeaderPrefix(String headerPrefix)
Changes the header prefix (a string that indicates the beginning of the header line for the COLUMNS format).


close

public void close()
           throws IOException
Flushes any pending data and closes the file or stream.

Throws:
IOException

SSJ
V. 2.6.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.