Class CSVFileWriter

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class CSVFileWriter
    extends CSVFile
    implements Closeable
    CSVFileWriter is a class derived from CSVFile used to format some fields into a new CSV file.
    Version:
    %I%, %G%
    Author:
    Fabrizio Fazzino
    • Constructor Detail

      • CSVFileWriter

        public CSVFileWriter​(String outputFileName)
                      throws IOException
        CSVFileWriter constructor just need the name of the CSV file that will be written.
        Parameters:
        outputFileName - The name of the CSV file to be opened for writing
        Throws:
        IOException - If an error occurs while creating the file
      • CSVFileWriter

        public CSVFileWriter​(String outputFileName,
                             char sep)
                      throws IOException
        CSVFileWriter constructor with a given field separator.
        Parameters:
        outputFileName - The name of the CSV file to be opened for reading
        sep - The field separator to be used; overwrites the default one
        Throws:
        IOException - If an error occurs while creating the file
      • CSVFileWriter

        public CSVFileWriter​(String outputFileName,
                             char sep,
                             char qual)
                      throws IOException
        CSVFileWriter constructor with given field separator and text qualifier.
        Parameters:
        outputFileName - The name of the CSV file to be opened for reading
        sep - The field separator to be used; overwrites the default one
        qual - The text qualifier to be used; overwrites the default one
        Throws:
        IOException - If an error occurs while creating the file
      • CSVFileWriter

        public CSVFileWriter​(String outputFileName,
                             boolean append)
                      throws IOException
        CSVFileWriter constructor just need the name of the CSV file that will be written.
        Parameters:
        outputFileName - The name of the CSV file to be opened for writing
        append - True if rows must be appended
        Throws:
        IOException - If an error occurs while creating the file
      • CSVFileWriter

        public CSVFileWriter​(String outputFileName,
                             char sep,
                             boolean append)
                      throws IOException
        CSVFileWriter constructor with a given field separator.
        Parameters:
        outputFileName - The name of the CSV file to be opened for reading
        sep - The field separator to be used; overwrites the default one
        append - True if rows must be appended
        Throws:
        IOException - If an error occurs while creating the file
      • CSVFileWriter

        public CSVFileWriter​(String outputFileName,
                             char sep,
                             char qual,
                             boolean append)
                      throws IOException
        CSVFileWriter constructor with given field separator and text qualifier.
        Parameters:
        outputFileName - The name of the CSV file to be opened for reading
        sep - The field separator to be used; overwrites the default one
        qual - The text qualifier to be used; overwrites the default one
        append - True if rows must be appended
        Throws:
        IOException - If an error occurs while creating the file
    • Method Detail

      • writeFields

        public void writeFields​(List<String> fields)
        Join the fields and write them as a new line to the CSV file.
        Parameters:
        fields - The vector of strings containing the fields