Package com.gengoai.io
Class CSVWriter
- java.lang.Object
-
- com.gengoai.io.CSVWriter
-
- All Implemented Interfaces:
AutoCloseable
public class CSVWriter extends Object implements AutoCloseable
Wraps writing collections and maps in DSV format to resources.
- Author:
- David B. Bracewell
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
write(Iterable<?> row)
Writes the items in the row to the resource in DSV format.void
write(Object... row)
Writes the items in the row to the resource in DSV format.void
write(Iterator<?> row)
Writes the items in the row to the resource in DSV format.void
write(Map<?,?> row)
Writes the items in the row to the resource in DSV format.void
write(Map<?,?> row, char keyValueSeparator)
Writes the items in the row to the resource in DSV format.
-
-
-
Constructor Detail
-
CSVWriter
public CSVWriter(CSV csv, Writer writer) throws IOException
Instantiates a new Csv writer.- Parameters:
csv
- the csvwriter
- the writer- Throws:
IOException
- the io exception
-
-
Method Detail
-
write
public void write(Iterable<?> row) throws IOException
Writes the items in the row to the resource in DSV format.- Parameters:
row
- the row- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
public void write(Iterator<?> row) throws IOException
Writes the items in the row to the resource in DSV format.- Parameters:
row
- the row- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
public void write(Map<?,?> row) throws IOException
Writes the items in the row to the resource in DSV format.- Parameters:
row
- the row- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
public void write(Map<?,?> row, char keyValueSeparator) throws IOException
Writes the items in the row to the resource in DSV format.- Parameters:
row
- the rowkeyValueSeparator
- the character to use to separate keys and values- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
public void write(Object... row) throws IOException
Writes the items in the row to the resource in DSV format.- Parameters:
row
- the row- Throws:
IOException
- Signals that an I/O exception has occurred.
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-
-