BeanIO 2.0.4

org.beanio.stream.csv
Class CsvWriter

java.lang.Object
  extended by org.beanio.stream.csv.CsvWriter
All Implemented Interfaces:
RecordWriter

public class CsvWriter
extends Object
implements RecordWriter

A CsvWriter is used to format and write records, of String arrays, to a CSV output stream. Using default settings, the CSV format supported is defined by specification RFC 4180.

The writer also supports the following customizations:

Since:
1.0
Author:
Kevin Seim

Constructor Summary
CsvWriter(Writer out)
          Constructs a new CsvWriter using default settings.
CsvWriter(Writer out, CsvParserConfiguration config)
          Constructs a new CsvWriter.
 
Method Summary
 void close()
          Closes the output stream.
 void flush()
          Flushes the output stream.
 int getLineNumber()
          Returns the last line number written to the output stream.
 void write(Object value)
          Writes a record object to this output stream.
 void write(String[] record)
          Formats and writes a record to this output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CsvWriter

public CsvWriter(Writer out)
Constructs a new CsvWriter using default settings. according the RFC 4180 specification.

Parameters:
out - the output stream to write to

CsvWriter

public CsvWriter(Writer out,
                 CsvParserConfiguration config)
Constructs a new CsvWriter.

Parameters:
out - the output stream to write to
config - the CsvParserConfiguration
Method Detail

getLineNumber

public int getLineNumber()
Returns the last line number written to the output stream.

Returns:
the last line number

write

public void write(Object value)
           throws IOException
Description copied from interface: RecordWriter
Writes a record object to this output stream.

Specified by:
write in interface RecordWriter
Parameters:
value - the record object to write
Throws:
IOException - if an I/O error occurs writing the record to the stream

write

public void write(String[] record)
           throws IOException
Formats and writes a record to this output stream.

Parameters:
record - the record to write
Throws:
IOException - if an I/O error occurs

flush

public void flush()
           throws IOException
Description copied from interface: RecordWriter
Flushes the output stream.

Specified by:
flush in interface RecordWriter
Throws:
IOException - if an I/O error occurs flushing the stream

close

public void close()
           throws IOException
Description copied from interface: RecordWriter
Closes the output stream.

Specified by:
close in interface RecordWriter
Throws:
IOException - if an I/O error occurs closing the stream

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim