org.skife.csv
Class SimpleWriter

java.lang.Object
  extended byorg.skife.csv.SimpleWriter
All Implemented Interfaces:
CSVWriter

public class SimpleWriter
extends java.lang.Object
implements CSVWriter

Provides primitive support for writing CSV files.


Constructor Summary
SimpleWriter(java.io.Writer out)
          Create a CSVWriter which prints output to a Writer.
 
Method Summary
static void append(java.io.File file, WriterCallback callback)
          Open a file and pass a writer to the callback which appends to that file.
 void append(java.lang.Object[] fields)
          Write a row to the CSV file
 void rawLine(java.lang.String line)
          Append a string as a raw line, without any processing
 void setAutoFlush(boolean autoFlush)
          Flush after each line? Default is false
 void setNewLine(char c)
          Defaults to the system dependent newline
 void setNewLine(char[] c)
          Defaults to the system dependent newline
 void setNewLine(java.lang.String newline)
          Defaults to the system dependent newline
 void setQuoteCharacters(char[] quotes)
          Specify an array of chars that will be treated as quotes, ie, will be ignored and everything between them is one field.
 void setSeperator(char seperator)
          Specify the character to use to seperate fields, defaults to a comma
static void write(java.io.File file, WriterCallback callback)
          Open a file and pass a writer to the callback which creates or overwrites that file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleWriter

public SimpleWriter(java.io.Writer out)
Create a CSVWriter which prints output to a Writer. It does not close the Writer.

Method Detail

append

public void append(java.lang.Object[] fields)
            throws java.io.IOException
Write a row to the CSV file

Specified by:
append in interface CSVWriter
Throws:
java.io.IOException

rawLine

public void rawLine(java.lang.String line)
             throws java.io.IOException
Append a string as a raw line, without any processing

Useful for comments, etc

Specified by:
rawLine in interface CSVWriter
Throws:
java.io.IOException

setSeperator

public void setSeperator(char seperator)
Specify the character to use to seperate fields, defaults to a comma

Specified by:
setSeperator in interface CSVWriter

setAutoFlush

public void setAutoFlush(boolean autoFlush)
Flush after each line? Default is false

Specified by:
setAutoFlush in interface CSVWriter

setNewLine

public void setNewLine(char c)
Defaults to the system dependent newline

Specified by:
setNewLine in interface CSVWriter

setNewLine

public void setNewLine(char[] c)
Defaults to the system dependent newline

Specified by:
setNewLine in interface CSVWriter

setNewLine

public void setNewLine(java.lang.String newline)
Defaults to the system dependent newline

Specified by:
setNewLine in interface CSVWriter

setQuoteCharacters

public void setQuoteCharacters(char[] quotes)
Specify an array of chars that will be treated as quotes, ie, will be ignored and everything between them is one field. Default is ' and "


write

public static void write(java.io.File file,
                         WriterCallback callback)
Open a file and pass a writer to the callback which creates or overwrites that file.

Throws:
java.lang.RuntimeException - if there is an exception during execution, flushing, or closing the file

append

public static void append(java.io.File file,
                          WriterCallback callback)
Open a file and pass a writer to the callback which appends to that file.

Throws:
java.lang.RuntimeException - if there is an exception during execution, flushing, or closing the file