Class CSVWriter

  • All Implemented Interfaces:
    AutoCloseable

    public class CSVWriter
    extends Object
    implements AutoCloseable

    Wraps writing collections and maps in DSV format to resources.

    Author:
    David B. Bracewell
    • Constructor Detail

      • CSVWriter

        public CSVWriter​(CSV csv,
                         Writer writer)
                  throws IOException
        Instantiates a new Csv writer.
        Parameters:
        csv - the csv
        writer - the writer
        Throws:
        IOException - the io exception
    • Method Detail

      • write

        public void write​(Iterable<?> row)
                   throws IOException
        Writes the items in the row to the resource in DSV format.
        Parameters:
        row - the row
        Throws:
        IOException - Signals that an I/O exception has occurred.
      • write

        public void write​(Iterator<?> row)
                   throws IOException
        Writes the items in the row to the resource in DSV format.
        Parameters:
        row - the row
        Throws:
        IOException - Signals that an I/O exception has occurred.
      • write

        public void write​(Map<?,​?> row)
                   throws IOException
        Writes the items in the row to the resource in DSV format.
        Parameters:
        row - the row
        Throws:
        IOException - Signals that an I/O exception has occurred.
      • write

        public void write​(Map<?,​?> row,
                          char keyValueSeparator)
                   throws IOException
        Writes the items in the row to the resource in DSV format.
        Parameters:
        row - the row
        keyValueSeparator - the character to use to separate keys and values
        Throws:
        IOException - Signals that an I/O exception has occurred.
      • write

        public void write​(Object... row)
                   throws IOException
        Writes the items in the row to the resource in DSV format.
        Parameters:
        row - the row
        Throws:
        IOException - Signals that an I/O exception has occurred.