CARVIEW |
Select Language
HTTP/2 200
server: GitHub.com
content-type: text/html; charset=utf-8
last-modified: Thu, 29 Oct 2015 19:20:12 GMT
access-control-allow-origin: *
etag: W/"5632716c-58d7"
expires: Thu, 24 Jul 2025 15:11:36 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: 76AC:269646:432D:4C5D:68824ACD
accept-ranges: bytes
age: 0
date: Thu, 24 Jul 2025 15:01:36 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210089-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753369296.098357,VS0,VE236
vary: Accept-Encoding
x-fastly-request-id: d884079221c01624502a656cfa31057787209a4c
content-length: 3832
CsvBeanWriter (Super CSV 2.4.0 API)
org.supercsv.io
Class CsvBeanWriter
- java.lang.Object
-
- org.supercsv.io.AbstractCsvWriter
-
- org.supercsv.io.CsvBeanWriter
-
- All Implemented Interfaces:
- Closeable, Flushable, AutoCloseable, ICsvBeanWriter, ICsvWriter
public class CsvBeanWriter extends AbstractCsvWriter implements ICsvBeanWriter
CsvBeanWriter writes a CSV file by mapping each field on the bean to a column in the CSV file (using the supplied name mapping).- Author:
- Kasper B. Graversen, James Bassett
-
-
Constructor Summary
Constructors Constructor and Description CsvBeanWriter(Writer writer, CsvPreference preference)
Constructs a new CsvBeanWriter with the supplied Writer and CSV preferences.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
write(Object source, String... nameMapping)
Writes the fields of the object as columns of a CSV file, using the supplied name mapping to map fields to the appropriate columns.void
write(Object source, String[] nameMapping, CellProcessor[] processors)
Writes the fields of the object as columns of a CSV file, using the supplied name mapping to map fields to the appropriate columns.-
Methods inherited from class org.supercsv.io.AbstractCsvWriter
close, flush, getLineNumber, getRowNumber, incrementRowAndLineNo, writeComment, writeHeader, writeRow, writeRow, writeRow
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.supercsv.io.ICsvWriter
getLineNumber, getRowNumber, writeComment, writeHeader
-
-
-
-
Constructor Detail
-
CsvBeanWriter
public CsvBeanWriter(Writer writer, CsvPreference preference)
Constructs a new CsvBeanWriter with the supplied Writer and CSV preferences. Note that the writer will be wrapped in a BufferedWriter before accessed.- Parameters:
writer
- the writerpreference
- the CSV preferences- Throws:
NullPointerException
- if writer or preference are null
-
-
Method Detail
-
write
public void write(Object source, String... nameMapping) throws IOException
Writes the fields of the object as columns of a CSV file, using the supplied name mapping to map fields to the appropriate columns. toString() will be called on each element prior to writing.- Specified by:
write
in interfaceICsvBeanWriter
- Parameters:
source
- the object (bean instance) containing the values to writenameMapping
- an array of Strings linking the fields in the bean to their corresponding CSV columns (the array length should match the number of columns). A null entry in the array indicates that the column should be ignored (the column will be empty).- Throws:
IOException
- if an I/O error occurred
-
write
public void write(Object source, String[] nameMapping, CellProcessor[] processors) throws IOException
Writes the fields of the object as columns of a CSV file, using the supplied name mapping to map fields to the appropriate columns. toString() will be called on each (processed) element prior to writing.- Specified by:
write
in interfaceICsvBeanWriter
- Parameters:
source
- the object (bean instance) containing the values to writenameMapping
- an array of Strings linking the fields in the bean to their corresponding CSV columns (the array length should match the number of columns). A null entry in the array indicates that the column should be ignored (the column will be empty).processors
- an array of CellProcessors used to further process data before it is written (each element in the processors array corresponds with a CSV column - the number of processors should match the number of columns). A null entry indicates no further processing is required (the value returned by toString() will be written as the column value).- Throws:
IOException
- if an I/O error occurred
-
-
Copyright © 2007–2015 Super CSV. All rights reserved.