Class AbstractWriter

  • Direct Known Subclasses:
    PPCWriter, RJEWriter

    public abstract class AbstractWriter
    extends java.lang.Object
    Base implementation for message writers.
    Messages are converted into its FIN representation and written into the output file with proper delimiters and length.
    The writer can be used in two different ways:
    • Writing messages directly into given Writer object, using the static write call method.
    • Instantiating the writer for a particular File or stream, calling the write methods and closing the writer when all messages has been written
    Since:
    7.8
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.io.Writer writer  
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractWriter​(java.io.File file)  
      AbstractWriter​(java.io.File _file, java.nio.charset.Charset _charset)
      Constructs a writer to write content into a file using the specified charset (or StandardCharsets.UTF_8 if null).
      AbstractWriter​(java.io.OutputStream stream)  
      AbstractWriter​(java.io.OutputStream _stream, java.nio.charset.Charset _charset)
      Constructs a writer to write content into a given stream using StandardCharsets.UTF_8.
      AbstractWriter​(java.io.Writer writer)
      Constructs a writer to write content into a given Writer instance.
      AbstractWriter​(java.lang.String filename)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close the stream.
      void flush()
      Flush the stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • writer

        protected java.io.Writer writer
    • Constructor Detail

      • AbstractWriter

        public AbstractWriter​(java.io.Writer writer)
        Constructs a writer to write content into a given Writer instance.
      • AbstractWriter

        public AbstractWriter​(java.io.File file)
                       throws java.io.FileNotFoundException
        Throws:
        java.io.FileNotFoundException
      • AbstractWriter

        public AbstractWriter​(java.lang.String filename)
                       throws java.io.FileNotFoundException
        Throws:
        java.io.FileNotFoundException
      • AbstractWriter

        public AbstractWriter​(java.io.File _file,
                              java.nio.charset.Charset _charset)
                       throws java.io.FileNotFoundException
        Constructs a writer to write content into a file using the specified charset (or StandardCharsets.UTF_8 if null).
        Parameters:
        _file - file to create
        _charset - charset
        Throws:
        java.io.FileNotFoundException - if file does not exist
      • AbstractWriter

        public AbstractWriter​(java.io.OutputStream stream)
      • AbstractWriter

        public AbstractWriter​(java.io.OutputStream _stream,
                              java.nio.charset.Charset _charset)
        Constructs a writer to write content into a given stream using StandardCharsets.UTF_8.
        Parameters:
        _stream - stream to write to
        _charset - charset
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Close the stream.
        Throws:
        java.io.IOException - if an I/O error occurs
      • flush

        public void flush()
                   throws java.io.IOException
        Flush the stream.
        Throws:
        java.io.IOException - if an I/O error occurs