Documentation of 'org.supercsv.io.AbstractCsvWriter' Java class
AbstractCsvWriter
org.supercsv.io

Class AbstractCsvWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable, ICsvWriter
    Direct Known Subclasses:
    CsvBeanWriter, CsvListWriter, CsvMapWriter


    public abstract class AbstractCsvWriter
    extends java.lang.Object
    implements ICsvWriter
    Defines the standard behaviour of a CSV writer.
    • Constructor Summary

      Constructors 
      Constructor and Description
      AbstractCsvWriter(java.io.Writer writer, CsvPreference preference)
      Constructs a new AbstractCsvWriter with the supplied writer and preferences.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void close()
      Closes the underlying writer, flushing it first.
      void flush()
      Flushes the underlying writer.
      int getLineNumber()
      Gets the current position in the file.
      int getRowNumber()
      Gets the current row number (i.e.
      void writeComment(java.lang.String comment)
      Writes a single-line comment to the CSV file (the comment must already include any special comment characters e.g.
      void writeHeader(java.lang.String... header)
      Writes the header of the CSV file.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractCsvWriter

        public AbstractCsvWriter(java.io.Writer writer,
                                 CsvPreference preference)
        Constructs a new AbstractCsvWriter with the supplied writer and preferences.
        Parameters:
        writer - the stream to write to
        preference - the CSV preferences
        Throws:
        java.lang.NullPointerException - if writer or preference are null
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Closes the underlying writer, flushing it first.
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Flushes the underlying writer.
        Specified by:
        flush in interface java.io.Flushable
        Throws:
        java.io.IOException
      • getLineNumber

        public int getLineNumber()
        Gets the current position in the file. The first line of the file is line number 1.
        Specified by:
        getLineNumber in interface ICsvWriter
      • getRowNumber

        public int getRowNumber()
        Gets the current row number (i.e. the number of CSV records - including the header - that have been written). This differs from the lineNumber, which is the number of real lines that have been written to the file. The first row is row 1 (which is typically the header row).
        Specified by:
        getRowNumber in interface ICsvWriter
      • writeComment

        public void writeComment(java.lang.String comment)
                          throws java.io.IOException
        Writes a single-line comment to the CSV file (the comment must already include any special comment characters e.g. '#' at start). Please note that comments are not part of RFC4180, so this may make your CSV file less portable.
        Specified by:
        writeComment in interface ICsvWriter
        Parameters:
        comment - the comment
        Throws:
        java.io.IOException - if an I/O error occurs
      • writeHeader

        public void writeHeader(java.lang.String... header)
                         throws java.io.IOException
        Writes the header of the CSV file.
        Specified by:
        writeHeader in interface ICsvWriter
        Parameters:
        header - one or more header Strings
        Throws:
        java.io.IOException - if an I/O error occurs

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.