Class LineWriter

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
    Direct Known Subclasses:
    ArrayOfRecordsExporter, CSVWriter, ExpressionWriter

    public class LineWriter
    extends Sink

    This actor reads string-valued input tokens and writes them, one line at a time, to a specified file. It does not include any enclosing quotation marks in the output. If you need the enclosing quotation marks, precede this actor with TokenToExpression.

    The file is specified by the fileName attribute using any form acceptable to FileParameter.

    If the append attribute has value true, then the file will be appended to. If it has value false, then if the file exists, the user will be queried for permission to overwrite, and if granted, the file will be overwritten.

    If the confirmOverwrite parameter has value false, then this actor will overwrite the specified file if it exists without asking. If true (the default), then if the file exists, then this actor will ask for confirmation before overwriting.

    Since:
    Ptolemy II 2.2
    Version:
    $Id$
    Author:
    Edward A. Lee
    See Also:
    FileParameter, ExpressionWriter
    Pt.AcceptedRating:
    Red (liuj)
    Pt.ProposedRating:
    Yellow (eal)
    • Field Detail

      • append

        public Parameter append
        If true, then append to the specified file. If false (the default), then overwrite any preexisting file after asking the user for permission.
      • fileName

        public FilePortParameter fileName
        The file name to which to write. This is a string with any form accepted by FilePortParameter. The default value is "System.out".
        See Also:
        FilePortParameter
      • confirmOverwrite

        public Parameter confirmOverwrite
        If false, then overwrite the specified file if it exists without asking. If true (the default), then if the file exists, ask for confirmation before overwriting.
      • endOfLineCharacter

        public Parameter endOfLineCharacter
        End of line character to use. This is a string that defaults to null, which results in the current platform's standard end-of-line character being used. If an empty string is specified, then no end of line character is used after each output written to the file.
      • alwaysFlush

        public Parameter alwaysFlush
        If true, flush output after each line is written. If false (the default), the output may not be written until the stream is closed during wrapup().
      • _flushValue

        protected boolean _flushValue
        If true, flush the writer after every write.
      • _writer

        protected java.io.PrintWriter _writer
        The current writer.