Class CSVFileWriter

java.lang.Object
  extended by CSVFile
      extended by CSVFileWriter

public class CSVFileWriter
extends CSVFile

CSVFileWriter is a class derived from CSVFile used to format some fields into a new CSV file.


Field Summary
protected  java.io.PrintWriter out
          The print writer linked to the CSV file to be written.
 
Fields inherited from class CSVFile
DEFAULT_FIELD_SEPARATOR, DEFAULT_TEXT_QUALIFIER, fieldSeparator, textQualifier
 
Constructor Summary
CSVFileWriter(java.lang.String outputFileName)
          CSVFileWriter constructor just need the name of the CSV file that will be written.
CSVFileWriter(java.lang.String outputFileName, char sep)
          CSVFileWriter constructor with a given field separator.
CSVFileWriter(java.lang.String outputFileName, char sep, char qual)
          CSVFileWriter constructor with given field separator and text qualifier.
 
Method Summary
 void close()
          Close the output CSV file.
 void writeFields(java.util.Vector<java.lang.String> fields)
          Join the fields and write them as a new line to the CSV file.
 
Methods inherited from class CSVFile
getFieldSeparator, getTextQualifier, setFieldSeparator, setTextQualifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

protected java.io.PrintWriter out
The print writer linked to the CSV file to be written.

Constructor Detail

CSVFileWriter

public CSVFileWriter(java.lang.String outputFileName)
              throws java.io.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:
java.io.IOException - If an error occurs while creating the file

CSVFileWriter

public CSVFileWriter(java.lang.String outputFileName,
                     char sep)
              throws java.io.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:
java.io.IOException - If an error occurs while creating the file

CSVFileWriter

public CSVFileWriter(java.lang.String outputFileName,
                     char sep,
                     char qual)
              throws java.io.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:
java.io.IOException - If an error occurs while creating the file
Method Detail

close

public void close()
           throws java.io.IOException
Close the output CSV file.

Throws:
java.io.IOException - If an error occurs while closing the file

writeFields

public void writeFields(java.util.Vector<java.lang.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