net.talvi.puffinplot.data
Class CsvWriter

java.lang.Object
  extended by net.talvi.puffinplot.data.CsvWriter

public class CsvWriter
extends java.lang.Object

This class provides a wrapper around a supplied Writer to allow easy writing of lines of data delimited by a particular string. Despite the name of the class, any string may be used as the delimiter.


Constructor Summary
CsvWriter(java.io.Writer writer)
          Creates a new CSV writer which will write to the specified writer using a comma as the field delimiter.
CsvWriter(java.io.Writer writer, java.lang.String separator)
          Creates a new CSV writer which will write to the specified writer and delimit fields with the specified string.
 
Method Summary
 void close()
          Closes the underlying writer supplied to this CSV writer's constructor.
 void writeCsv(java.lang.Object... objects)
          Writes a line to the writer provided to the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CsvWriter

public CsvWriter(java.io.Writer writer,
                 java.lang.String separator)
Creates a new CSV writer which will write to the specified writer and delimit fields with the specified string.

Parameters:
writer - the writer to which to write
separator - the separator which will be placed between the fields

CsvWriter

public CsvWriter(java.io.Writer writer)
Creates a new CSV writer which will write to the specified writer using a comma as the field delimiter.

Parameters:
writer - writer the writer to which to write
Method Detail

writeCsv

public void writeCsv(java.lang.Object... objects)
              throws java.io.IOException
Writes a line to the writer provided to the constructor. The line consists of strings representations of each of the provided objects, separated by the field delimiter configured for this CSV writer.

Parameters:
objects - the objects to write
Throws:
java.io.IOException - if an I/O error occurs during writing

close

public void close()
           throws java.io.IOException
Closes the underlying writer supplied to this CSV writer's constructor.

Throws:
java.io.IOException - if an I/O error occurs