org.jacoco.report.csv
Class DelimitedWriter

java.lang.Object
  extended by org.jacoco.report.csv.DelimitedWriter

public class DelimitedWriter
extends Object

Helper class for writing out CSV or tab delimited files.

Example Usage:

 delimitedWriter.writeFields("header1", "header2", ...);
 for each line to be written {
   delimitedWriter.writeField(value1);
   delimitedWriter.writeField(value2);
   delimitedWriter.nextLine();
 }
 delimitedWriter.close();
 

Version:
0.4.1.20101007204400
Author:
Brock Janiczak

Constructor Summary
DelimitedWriter(Writer delegate)
          Creates a new Delimited writer using the default delimiter
DelimitedWriter(Writer delegate, char delimiter)
          Creates a new Delimited writer using the default delimiter
 
Method Summary
 void close()
          Close the underlying writer object.
 void nextLine()
          Output a new line and advance the writer to the next line.
 void write(int... values)
          Write muliple integer values
 void write(int value)
          Write a single integer value.
 void write(String... fields)
          Write multiple fields at once.
 void write(String field)
          Write a single value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelimitedWriter

public DelimitedWriter(Writer delegate)
Creates a new Delimited writer using the default delimiter

Parameters:
delegate - Writer to delegate all writes to

DelimitedWriter

public DelimitedWriter(Writer delegate,
                       char delimiter)
Creates a new Delimited writer using the default delimiter

Parameters:
delegate - Writer to delegate all writes to
delimiter - delimiter to use (usually a comma, tab or space)
Method Detail

write

public void write(String... fields)
           throws IOException
Write multiple fields at once. Values will be auto escaped and quoted as needed. Each value will be separated using the current delimiter

Parameters:
fields - Values to write
Throws:
IOException - Error writing to the underlying writer object

write

public void write(String field)
           throws IOException
Write a single value. Values will be auto escaped and quoted as needed. If this is not the first field of the current line the value will be prepended with the current delimiter

Parameters:
field - Value to write
Throws:
IOException - Error writing to the underlying writer object

write

public void write(int value)
           throws IOException
Write a single integer value.

Parameters:
value - Value to write
Throws:
IOException - Error writing to the underlying writer object

write

public void write(int... values)
           throws IOException
Write muliple integer values

Parameters:
values - values to write
Throws:
IOException - Error writing to the underlying writer object

nextLine

public void nextLine()
              throws IOException
Output a new line and advance the writer to the next line. The line delimiter is the default for the platform.

Throws:
IOException - Error writing to the underlying writer object

close

public void close()
           throws IOException
Close the underlying writer object. Once closed all write operations will fail

Throws:
IOException - Error closing the underlying writer object