Class TextStreamWriter

Direct Known Subclasses:
JsonRecordWriter, XmlRecordWriter

public abstract class TextStreamWriter extends DataWriter
Abstract super-class for writing records to a text stream. Unike TextWriter, this writer doesn't force the concept of fieldNamesInFirstRow and doesn't assume the output is line based.
  • Constructor Details

    • TextStreamWriter

      public TextStreamWriter(File file)
      Creates a writer that overwrites the file, which this constructor opens immediately rather than in open().
    • TextStreamWriter

      public TextStreamWriter(Writer writer)
  • Method Details

    • getWriter

      public BufferedWriter getWriter()
    • getFile

      public File getFile()
      Returns the target file or null if this writer was created from a Writer.
    • isAutoCloseWriter

      public boolean isAutoCloseWriter()
      Indicates if the underlying java.io.BufferedWriter should be closed when this stream closes (defaults to true).
    • setAutoCloseWriter

      public TextStreamWriter setAutoCloseWriter(boolean autoCloseWriter)
      Indicates if the underlying java.io.BufferedWriter should be closed when this stream closes (defaults to true).
    • isFlushOnWrite

      public boolean isFlushOnWrite()
      Indicates if the underlying java.io.BufferedWriter should be flushed after each record is written.
    • setFlushOnWrite

      public TextStreamWriter setFlushOnWrite(boolean flushOnWrite)
      Indicates if the underlying java.io.BufferedWriter should be flushed after each record is written (defaults to false).
    • close

      public void close()
      Description copied from class: DataEndpoint
      Indicates that this endpoint has finished reading or writing.
      Overrides:
      close in class DataEndpoint
    • write

      public void write(Record record) throws DataException
      Description copied from class: DataWriter
      Writes the specified record to this DataWriter and increases the record-count by 1. Any exception raised while writing will be converted to a DataException using DataObject.exception(Throwable).

      Subclasses generally do not need to override this method, instead they should implement DataWriter.writeImpl(Record).

      Overrides:
      write in class DataWriter
      Throws:
      DataException
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Description copied from class: Endpoint
      Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Overrides:
      addExceptionProperties in class DataWriter