|
Jive Forums API (5.5.20.2-oracle) Developer Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.Writer
com.jivesoftware.base.stats.output.CSVWriter
public class CSVWriter
A writer which outputs DataTable data as CSV (comma-separated values) output.
Sample usage:
CSVWriter writer = new CVSWriter(new FileWriter(new File("out.csv")));Using the
DataTable table = // get a data table
writer.write(table);
writeTitle(String)
, writeColumns(String[])
, writeRow(Object[])
methods
you can create CSV output without using a DataTable. Finally, there is a convience method to escape a given String for a CSV file (removes commas). See the
escapeForCSV(String)
method for more details.
DataTable
Field Summary |
---|
Fields inherited from class java.io.Writer |
---|
lock |
Constructor Summary | |
---|---|
CSVWriter(java.io.Writer writer)
Creates a new CSV writer given a writer. |
Method Summary | |
---|---|
void |
close()
|
static java.lang.String |
escapeForCSV(java.lang.String str)
Escapes a given string for CSV output by removing commas with a blank character. |
void |
flush()
|
void |
write(char[] cbuf,
int off,
int len)
|
void |
writeColumns(java.lang.String[] columns)
Writes an array of columns out in CSV format. |
void |
writeCSV(DataTable table)
Writes the entire table out in CSV format. |
void |
writeRow(java.lang.Object[] row)
Writes a row out as CSV data. |
void |
writeTitle(java.lang.String title)
Write just the title of the CSV file. |
Methods inherited from class java.io.Writer |
---|
append, append, append, write, write, write, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CSVWriter(java.io.Writer writer)
writer
- the writer to write CSV output to.Method Detail |
---|
public void write(char[] cbuf, int off, int len) throws java.io.IOException
write
in class java.io.Writer
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.Writer
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.Writer
java.io.IOException
public void writeCSV(DataTable table) throws java.io.IOException
table
- the data table to write.
java.io.IOException
- if an exception occurs when writing the data.public void writeTitle(java.lang.String title) throws java.io.IOException
title
- the title of the
java.io.IOException
public void writeColumns(java.lang.String[] columns) throws java.io.IOException
columns
- an array of column names.
java.io.IOException
- if an exception occurs when writing the columns.public void writeRow(java.lang.Object[] row) throws java.io.IOException
row
- the row data.
java.io.IOException
- if an exception occurs when writing out the data.public static java.lang.String escapeForCSV(java.lang.String str)
str
- the string to escape.
|
Jive Forums Project Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |