You are on page 1of 49

Skip navigation links <#skip.navbar.

top>

* Package
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/package-summary.html>
* Class
* Use
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/class-use/CSVFormat.html>
* Tree
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/package-tree.html>
* Deprecated
<https://commons.apache.org/proper/commons-csv/apidocs/deprecated-list.html>
* Index
<https://commons.apache.org/proper/commons-csv/apidocs/index-all.html>
* Help
<https://commons.apache.org/proper/commons-csv/apidocs/help-doc.html>

* Prev Class
* Next Class
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html>

* Frames
<https://commons.apache.org/proper/commons-csv/apidocs/index.html?
org/apache/commons/csv/CSVFormat.html>
* No Frames
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>

* All Classes
<https://commons.apache.org/proper/commons-csv/apidocs/allclasses-noframe.html>

* Summary:
* Nested <#nested.class.summary> |
* Field <#field.summary> |
* Constr |
* Method <#method.summary>

* Detail:
* Field <#field.detail> |
* Constr |
* Method <#method.detail>

org.apache.commons.csv

Class CSVFormat

* java.lang.Object
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true>
*
o org.apache.commons.csv.CSVFormat

All Implemented Interfaces:


Serializable
<http://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html?is-
external=true>

------------------------------------------------------------------------

public final class CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/src-html/org/apache/commons/csv/CSVFormat.html#line.156>
extends Object <http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?
is-external=true>
implements Serializable
<http://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html?is-
external=true>

Specifies the format of a CSV file and parses input.

Using predefined formats

You can use one of the predefined formats:

o |DEFAULT|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#DEFAULT>
o |EXCEL|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#EXCEL>
o |MYSQL|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#MYSQL>
o |RFC4180|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#RFC4180>
o |TDF|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#TDF>

For example:

CSVParser parser = CSVFormat.EXCEL.parse(reader);

The |CSVParser|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVParser.html>
provides static methods to parse other input types, for example:

CSVParser parser = CSVParser.parse(file, StandardCharsets.US_ASCII,


CSVFormat.EXCEL);

Defining formats

You can extend a format by calling the |with| methods. For example:

CSVFormat.EXCEL.withNullString("N/A").withIgnoreSurroundingSpaces(true);
Defining column names

To define the column names you want to use to access records, write:

CSVFormat.EXCEL.withHeader("Col1", "Col2", "Col3");

Calling |withHeader(String...)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withHeader-java.lang.String...->
let's you use the given names to address values in a |CSVRecord|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVRecord.html>,
and assumes that your CSV source does not contain a first record
that also defines column names. If it does, then you are overriding
this metadata with your names and you should skip the first record
by calling |withSkipHeaderRecord(boolean)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withSkipHeaderRecord-boolean->
with |true|.

Parsing

You can use a format directly to parse a reader. For example, to


parse an Excel file with columns header, write:

Reader in = ...;
CSVFormat.EXCEL.withHeader("Col1", "Col2", "Col3").parse(in);

For other input types, like resources, files, and URLs, use the
static methods on |CSVParser|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVParser.html>.

Referencing columns safely

If your source contains a header record, you can simplify your code
and safely reference columns, by using |withHeader(String...)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withHeader-java.lang.String...->
with no arguments:

CSVFormat.EXCEL.withHeader();

This causes the parser to read the first record and use its values
as column names. Then, call one of the |CSVRecord|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVRecord.html>
get method that takes a String column name argument:

String value = record.get("Col1");


This makes your code impervious to changes in column order in the
CSV file.

Notes

This class is immutable.

See Also:
Serialized Form
<https://commons.apache.org/proper/commons-csv/apidocs/serialized-
form.html#org.apache.commons.csv.CSVFormat>

*
o

Nested Class Summary

Nested Classes Modifier and Type Class and Description


|static class | |CSVFormat.Predefined
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html>|

Predefines formats.

Field Summary

Fields Modifier and Type Field and Description


|static CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|DEFAULT
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#DEFAULT>|

Standard comma separated format, as for |RFC4180|


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#RFC4180>
but allowing empty lines.
|static CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|EXCEL
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#EXCEL>|

Excel file format (using a comma as the value delimiter).


|static CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|INFORMIX_UNLOAD
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#INFORMIX_UNLOAD>|

Default Informix CSV UNLOAD format used by the |UNLOAD TO


file_name| operation.
|static CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|INFORMIX_UNLOAD_CSV
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#INFORMIX_UNLOAD_CSV>|

Default Informix CSV UNLOAD format used by the |UNLOAD TO


file_name| operation (escaping is disabled.)
|static CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|MYSQL
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#MYSQL>|

Default MySQL format used by the |SELECT INTO OUTFILE| and |LOAD
DATA INFILE| operations.
|static CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|POSTGRESQL_CSV
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#POSTGRESQL_CSV>|

Default PostgreSQL CSV format used by the |COPY| operation.


|static CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|POSTGRESQL_TEXT
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#POSTGRESQL_TEXT>|

Default PostgreSQL text format used by the |COPY| operation.


|static CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|RFC4180
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#RFC4180>|

Comma separated format as defined by RFC 4180


<http://tools.ietf.org/html/rfc4180>.
|static CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|TDF
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#TDF>|

Tab-delimited format.

Method Summary

All Methods Static Methods <javascript:show(1);> Instance


Methods <javascript:show(2);> Concrete Methods
<javascript:show(8);> Modifier and Type Method and Description
|boolean| |equals
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#equals-java.lang.Object->(Object
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true> obj)|

|String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-
external=true>|
|format
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#format-java.lang.Object...-
>(Object
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true>... values)|

Formats the specified values.


|boolean| |getAllowMissingColumnNames
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getAllowMissingColumnNames-->()|

Specifies whether missing column names are allowed when parsing


the header line.
|Character
<http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html?is-
external=true>|
|getCommentMarker
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getCommentMarker-->()|

Returns the character marking the start of a line comment.


|char| |getDelimiter
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getDelimiter-->()|

Returns the character delimiting the values (typically ';', ','


or '\t').
|Character
<http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html?is-
external=true>|
|getEscapeCharacter
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getEscapeCharacter-->()|

Returns the escape character.


|String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-
external=true>[]|
|getHeader
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getHeader-->()|

Returns a copy of the header array.


|String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-
external=true>[]|
|getHeaderComments
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getHeaderComments-->()|

Returns a copy of the header comment array.


|boolean| |getIgnoreEmptyLines
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getIgnoreEmptyLines-->()|

Specifies whether empty lines between records are ignored when


parsing input.
|boolean| |getIgnoreHeaderCase
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getIgnoreHeaderCase-->()|

Specifies whether header names will be accessed ignoring case.


|boolean| |getIgnoreSurroundingSpaces
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getIgnoreSurroundingSpaces-->()|

Specifies whether spaces around values are ignored when parsing


input.
|String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-
external=true>|
|getNullString
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getNullString-->()|

Gets the String to convert to and from |null|.


|Character
<http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html?is-
external=true>|
|getQuoteCharacter
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getQuoteCharacter-->()|

Returns the character used to encapsulate values containing


special characters.
|QuoteMode
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/QuoteMode.html>|
|getQuoteMode
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getQuoteMode-->()|

Returns the quote policy output fields.


|String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-
external=true>|
|getRecordSeparator
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getRecordSeparator-->()|

Returns the record separator delimiting output records.


|boolean| |getSkipHeaderRecord
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getSkipHeaderRecord-->()|

Returns whether to skip the header record.


|boolean| |getTrailingDelimiter
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getTrailingDelimiter-->()|

Returns whether to add a trailing delimiter.


|boolean| |getTrim
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#getTrim-->()|

Returns whether to trim leading and trailing blanks.


|int| |hashCode
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#hashCode-->()|

|boolean| |isCommentMarkerSet
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#isCommentMarkerSet-->()|

Specifies whether comments are supported by this format.


|boolean| |isEscapeCharacterSet
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#isEscapeCharacterSet-->()|

Returns whether escape are being processed.


|boolean| |isNullStringSet
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#isNullStringSet-->()|

Returns whether a nullString has been defined.


|boolean| |isQuoteCharacterSet
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#isQuoteCharacterSet-->()|

Returns whether a quoteChar has been defined.


|static CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|newFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#newFormat-char->(char delimiter)|

Creates a new CSV format with the specified delimiter.


|CSVParser
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVParser.html>|
|parse
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#parse-java.io.Reader->(Reader
<http://docs.oracle.com/javase/7/docs/api/java/io/Reader.html?is-
external=true> in)|

Parses the specified content.


|CSVPrinter
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVPrinter.html>|
|print
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#print-java.lang.Appendable-
>(Appendable
<http://docs.oracle.com/javase/7/docs/api/java/lang/Appendable.html?is-
external=true> out)|

Prints to the specified output.


|CSVPrinter
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVPrinter.html>|
|print
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#print-java.io.File-
java.nio.charset.Charset->(File
<http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-
external=true> out,
Charset
<http://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html?is-
external=true> charset)|

Prints to the specified output.


|void| |print
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#print-java.lang.Object-
java.lang.Appendable-boolean->(Object
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true> value,
Appendable
<http://docs.oracle.com/javase/7/docs/api/java/lang/Appendable.html?is-
external=true> out,
boolean newRecord)|
Prints the |value| as the next value on the line to |out|.
|CSVPrinter
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVPrinter.html>|
|print
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#print-java.nio.file.Path-
java.nio.charset.Charset->(Path
<http://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html?is-
external=true> out,
Charset
<http://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html?is-
external=true> charset)|

Prints to the specified output.


|CSVPrinter
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVPrinter.html>|
|printer
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#printer-->()|

Prints to the |System.out|


<http://docs.oracle.com/javase/7/docs/api/java/lang/System.html?is-
external=true#out>.
|void| |println
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#println-java.lang.Appendable-
>(Appendable
<http://docs.oracle.com/javase/7/docs/api/java/lang/Appendable.html?is-
external=true> out)|
Outputs the trailing delimiter (if set) followed by the record
separator (if set).
|void| |printRecord
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#printRecord-java.lang.Appendable-
java.lang.Object...->(Appendable
<http://docs.oracle.com/javase/7/docs/api/java/lang/Appendable.html?is-
external=true> out,
Object
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true>... values)|

Prints the given |values| to |out| as a single record of


delimiter separated values followed by the record separator.
|String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-
external=true>|
|toString
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#toString-->()|

|static CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|valueOf
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#valueOf-java.lang.String->(String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-
external=true> format)|

Gets one of the predefined formats from |CSVFormat.Predefined|


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html>.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withAllowMissingColumnNames
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withAllowMissingColumnNames-->()|

Returns a new |CSVFormat| with the missing column names behavior


of the format set to |true|
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withAllowMissingColumnNames
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withAllowMissingColumnNames-
boolean->(boolean allowMissingColumnNames)|

Returns a new |CSVFormat| with the missing column names behavior


of the format set to the given value.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withCommentMarker
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withCommentMarker-char->(char
commentMarker)|

Returns a new |CSVFormat| with the comment start marker of the


format set to the specified character.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withCommentMarker
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withCommentMarker-
java.lang.Character->(Character
<http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html?is-
external=true> commentMarker)|

Returns a new |CSVFormat| with the comment start marker of the


format set to the specified character.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withDelimiter
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withDelimiter-char->(char
delimiter)|

Returns a new |CSVFormat| with the delimiter of the format set


to the specified character.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withEscape
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withEscape-char->(char escape)|

Returns a new |CSVFormat| with the escape character of the


format set to the specified character.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withEscape
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withEscape-java.lang.Character-
>(Character
<http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html?is-
external=true> escape)|

Returns a new |CSVFormat| with the escape character of the


format set to the specified character.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withFirstRecordAsHeader
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withFirstRecordAsHeader-->()|

Returns a new |CSVFormat| using the first record as header.


|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withHeader
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withHeader-java.lang.Class-
>(Class
<http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html?is-
external=true><?
extends Enum
<http://docs.oracle.com/javase/7/docs/api/java/lang/Enum.html?is-
external=true><?>> headerEnum)|

Returns a new |CSVFormat| with the header of the format defined


by the enum class.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withHeader
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withHeader-java.sql.ResultSet-
>(ResultSet
<http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.html?is-
external=true> resultSet)|

Returns a new |CSVFormat| with the header of the format set from
the result set metadata.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withHeader
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withHeader-
java.sql.ResultSetMetaData->(ResultSetMetaData
<http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSetMetaData.html?
is-external=true> metaData)|

Returns a new |CSVFormat| with the header of the format set from
the result set metadata.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withHeader
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withHeader-java.lang.String...-
>(String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-
external=true>... header)|

Returns a new |CSVFormat| with the header of the format set to


the given values.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withHeaderComments
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withHeaderComments-
java.lang.Object...->(Object
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true>... headerComments)|

Returns a new |CSVFormat| with the header comments of the format


set to the given values.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withIgnoreEmptyLines
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withIgnoreEmptyLines-->()|

Returns a new |CSVFormat| with the empty line skipping behavior


of the format set to |true|.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withIgnoreEmptyLines
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withIgnoreEmptyLines-boolean-
>(boolean ignoreEmptyLines)|

Returns a new |CSVFormat| with the empty line skipping behavior


of the format set to the given value.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withIgnoreHeaderCase
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withIgnoreHeaderCase-->()|

Returns a new |CSVFormat| with the header ignore case behavior


set to |true|.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withIgnoreHeaderCase
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withIgnoreHeaderCase-boolean-
>(boolean ignoreHeaderCase)|

Returns a new |CSVFormat| with whether header names should be


accessed ignoring case.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withIgnoreSurroundingSpaces
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withIgnoreSurroundingSpaces-->()|

Returns a new |CSVFormat| with the trimming behavior of the


format set to |true|.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withIgnoreSurroundingSpaces
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withIgnoreSurroundingSpaces-
boolean->(boolean ignoreSurroundingSpaces)|

Returns a new |CSVFormat| with the trimming behavior of the


format set to the given value.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withNullString
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withNullString-java.lang.String-
>(String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-
external=true> nullString)|

Returns a new |CSVFormat| with conversions to and from null for


strings on input and output.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withQuote
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withQuote-char->(char quoteChar)|

Returns a new |CSVFormat| with the quoteChar of the format set


to the specified character.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withQuote
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withQuote-java.lang.Character-
>(Character
<http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html?is-
external=true> quoteChar)|

Returns a new |CSVFormat| with the quoteChar of the format set


to the specified character.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withQuoteMode
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withQuoteMode-
org.apache.commons.csv.QuoteMode->(QuoteMode
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/QuoteMode.html> quoteModePolicy)|

Returns a new |CSVFormat| with the output quote policy of the


format set to the specified value.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withRecordSeparator
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withRecordSeparator-char->(char
recordSeparator)|

Returns a new |CSVFormat| with the record separator of the


format set to the specified character.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withRecordSeparator
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withRecordSeparator-
java.lang.String->(String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-
external=true> recordSeparator)|

Returns a new |CSVFormat| with the record separator of the


format set to the specified String.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withSkipHeaderRecord
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withSkipHeaderRecord-->()|

Returns a new |CSVFormat| with skipping the header record set to


|true|.
|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withSkipHeaderRecord
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withSkipHeaderRecord-boolean-
>(boolean skipHeaderRecord)|

Returns a new |CSVFormat| with whether to skip the header record.


|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withTrailingDelimiter
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withTrailingDelimiter-->()|

Returns a new |CSVFormat| to add a trailing delimiter.


|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withTrailingDelimiter
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withTrailingDelimiter-boolean-
>(boolean trailingDelimiter)|

Returns a new |CSVFormat| with whether to add a trailing delimiter.


|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withTrim
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withTrim-->()|

Returns a new |CSVFormat| to trim leading and trailing blanks.


|CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>|
|withTrim
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withTrim-boolean->(boolean trim)|

Returns a new |CSVFormat| with whether to trim leading and


trailing blanks.
+

Methods inherited from class java.lang.Object


<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?
is-external=true>

|clone
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true#clone-->,
finalize
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true#finalize-->,
getClass
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true#getClass-->,
notify
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true#notify-->,
notifyAll
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true#notifyAll-->,
wait
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true#wait-->,
wait
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true#wait-long->,
wait
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true#wait-long-int->|

*
o

Field Detail

DEFAULT

public static final CSVFormat


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html> DEFAULT
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.244>

Standard comma separated format, as for |RFC4180|


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#RFC4180>
but allowing empty lines.

Settings are:

# withDelimiter(',')
# withQuote('"')
# withRecordSeparator("\r\n")
# withIgnoreEmptyLines(true)

See Also:
|CSVFormat.Predefined.Default|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html#Default>

EXCEL

public static final CSVFormat


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html> EXCEL
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.277>

Excel file format (using a comma as the value delimiter).


Note that the actual value delimiter used by Excel is locale
dependent, it might be necessary to customize this format to
accommodate to your regional settings.

For example for parsing or generating a CSV file on a French


system the following format will be used:

CSVFormat fmt = CSVFormat.EXCEL.withDelimiter(';');

Settings are:

# |withDelimiter(',')|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withDelimiter-char->
# |withQuote('"')|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withQuote-char->
# |withRecordSeparator("\r\n")|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withRecordSeparator-
java.lang.String->
# |withIgnoreEmptyLines(false)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withIgnoreEmptyLines-boolean->
# |withAllowMissingColumnNames(true)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withAllowMissingColumnNames-
boolean->

Note: this is currently like |RFC4180|


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#RFC4180>
plus |withAllowMissingColumnNames(true)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withAllowMissingColumnNames-
boolean->.

See Also:
|CSVFormat.Predefined.Excel|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html#Excel>

INFORMIX_UNLOAD

public static final CSVFormat


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html> INFORMIX_UNLOAD
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.307>

Default Informix CSV UNLOAD format used by the |UNLOAD TO


file_name| operation.

This is a comma-delimited format with a LF character as the


line separator. Values are not quoted and special characters
are escaped with |'\'|. The default NULL string is |"\\N"|.

Settings are:

# withDelimiter(',')
# withQuote("\"")
# withRecordSeparator('\n')
# withEscape('\\')

Since:
1.3
See Also:
|CSVFormat.Predefined.MySQL|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html#MySQL>,

http://www.ibm.com/support/knowledgecenter/SSBJG3_2.5.0/com.ibm.gen_busug.doc/c_fgl
_InOutSql_UNLOAD.htm

<http://www.ibm.com/support/knowledgecenter/SSBJG3_2.5.0/com.ibm.gen_busug.doc/c_fg
l_InOutSql_UNLOAD.htm>

INFORMIX_UNLOAD_CSV

public static final CSVFormat


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html> INFORMIX_UNLOAD_CSV
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.338>

Default Informix CSV UNLOAD format used by the |UNLOAD TO


file_name| operation (escaping is disabled.)

This is a comma-delimited format with a LF character as the


line separator. Values are not quoted and special characters
are escaped with |'\'|. The default NULL string is |"\\N"|.
Settings are:

# withDelimiter(',')
# withQuote("\"")
# withRecordSeparator('\n')

Since:
1.3
See Also:
|CSVFormat.Predefined.MySQL|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html#MySQL>,

http://www.ibm.com/support/knowledgecenter/SSBJG3_2.5.0/com.ibm.gen_busug.doc/c_fgl
_InOutSql_UNLOAD.htm

<http://www.ibm.com/support/knowledgecenter/SSBJG3_2.5.0/com.ibm.gen_busug.doc/c_fg
l_InOutSql_UNLOAD.htm>

MYSQL

public static final CSVFormat


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html> MYSQL
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.370>

Default MySQL format used by the |SELECT INTO OUTFILE| and


|LOAD DATA INFILE| operations.

This is a tab-delimited format with a LF character as the


line separator. Values are not quoted and special characters
are escaped with |'\'|. The default NULL string is |"\\N"|.

Settings are:

# withDelimiter('\t')
# withQuote(null)
# withRecordSeparator('\n')
# withIgnoreEmptyLines(false)
# withEscape('\\')
# withNullString("\\N")
# withQuoteMode(QuoteMode.ALL_NON_NULL)

See Also:
|CSVFormat.Predefined.MySQL|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html#MySQL>,
http://dev.mysql.com/doc/refman/5.1/en/load -data.html
<http://dev.mysql.com/doc/refman/5.1/en/load-data.html>

POSTGRESQL_CSV
public static final CSVFormat
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html> POSTGRESQL_CSV
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.407>

Default PostgreSQL CSV format used by the |COPY| operation.

This is a comma-delimited format with a LF character as the


line separator. Values are double quoted and special
characters are escaped with |'"'|. The default NULL string
is |""|.

Settings are:

# withDelimiter(',')
# withQuote('"')
# withRecordSeparator('\n')
# withIgnoreEmptyLines(false)
# withEscape('\\')
# withNullString("")
# withQuoteMode(QuoteMode.ALL_NON_NULL)

Since:
1.5
See Also:
|CSVFormat.Predefined.MySQL|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html#MySQL>,
http://dev.mysql.com/doc/refman/5.1/en/load -data.html
<http://dev.mysql.com/doc/refman/5.1/en/load-data.html>

POSTGRESQL_TEXT

public static final CSVFormat


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html> POSTGRESQL_TEXT
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.444>

Default PostgreSQL text format used by the |COPY| operation.

This is a tab-delimited format with a LF character as the


line separator. Values are double quoted and special
characters are escaped with |'"'|. The default NULL string
is |"\\N"|.

Settings are:

# withDelimiter('\t')
# withQuote('"')
# withRecordSeparator('\n')
# withIgnoreEmptyLines(false)
# withEscape('\\')
# withNullString("\\N")
# withQuoteMode(QuoteMode.ALL_NON_NULL)

Since:
1.5
See Also:
|CSVFormat.Predefined.MySQL|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html#MySQL>,
http://dev.mysql.com/doc/refman/5.1/en/load -data.html
<http://dev.mysql.com/doc/refman/5.1/en/load-data.html>

RFC4180

public static final CSVFormat


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html> RFC4180
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.469>

Comma separated format as defined by RFC 4180


<http://tools.ietf.org/html/rfc4180>.

Settings are:

# withDelimiter(',')
# withQuote('"')
# withRecordSeparator("\r\n")
# withIgnoreEmptyLines(false)

See Also:
|CSVFormat.Predefined.RFC4180|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html#RFC4180>

TDF

public static final CSVFormat


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html> TDF
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.489>

Tab-delimited format.

Settings are:

# withDelimiter('\t')
# withQuote('"')
# withRecordSeparator("\r\n")
# withIgnoreSurroundingSpaces(true)

See Also:
|CSVFormat.Predefined.TDF|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html#TDF>

Method Detail

newFormat

public static CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> newFormat
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.538>(char delimiter)

Creates a new CSV format with the specified delimiter.

Use this method if you want to create a CSVFormat from


scratch. All fields but the delimiter will be initialized
with null/false.

Parameters:
|delimiter| - the char used for value separation, must
not be a line break character
Returns:
a new CSV format.
Throws:
|IllegalArgumentException

<http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?
is-external=true>|
- if the delimiter is a line break character
See Also:
|DEFAULT|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#DEFAULT>,
|RFC4180|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#RFC4180>,
|MYSQL|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#MYSQL>,
|EXCEL|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#EXCEL>,
|TDF|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#TDF>

valueOf

public static CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> valueOf
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.551>(String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true>
format)

Gets one of the predefined formats from


|CSVFormat.Predefined|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html>.

Parameters:
|format| - name
Returns:
one of the predefined formats
Since:
1.2

equals

public boolean equals <https://commons.apache.org/proper/commons-


csv/apidocs/src-html/org/apache/commons/csv/CSVFormat.html#line.651>(Object
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true>
obj)

Overrides:
|equals
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true#equals-java.lang.Object->| in
class |Object
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true>|

format

public String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true>
format <https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.726>(Object
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true>... values)

Formats the specified values.

Parameters:
|values| - the values to format
Returns:
the formatted values

getAllowMissingColumnNames
public boolean getAllowMissingColumnNames
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.743>()

Specifies whether missing column names are allowed when


parsing the header line.

Returns:
|true| if missing column names are allowed when parsing
the header line, |false| to throw an
|IllegalArgumentException|

<http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?
is-external=true>.

getCommentMarker

public Character
<http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html?is-
external=true> getCommentMarker <https://commons.apache.org/proper/commons-
csv/apidocs/src-html/org/apache/commons/csv/CSVFormat.html#line.752>()

Returns the character marking the start of a line comment.

Returns:
the comment start marker, may be |null|

getDelimiter

public char getDelimiter <https://commons.apache.org/proper/commons-


csv/apidocs/src-html/org/apache/commons/csv/CSVFormat.html#line.761>()

Returns the character delimiting the values (typically ';',


',' or '\t').

Returns:
the delimiter character

getEscapeCharacter

public Character
<http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html?is-
external=true> getEscapeCharacter <https://commons.apache.org/proper/commons-
csv/apidocs/src-html/org/apache/commons/csv/CSVFormat.html#line.770>()

Returns the escape character.

Returns:
the escape character, may be |null|
+

getHeader

public String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true>[]
getHeader <https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.779>()

Returns a copy of the header array.

Returns:
a copy of the header array; |null| if disabled, the
empty array if to be read from the file

getHeaderComments

public String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true>[]
getHeaderComments <https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.788>()

Returns a copy of the header comment array.

Returns:
a copy of the header comment array; |null| if disabled.

getIgnoreEmptyLines

public boolean getIgnoreEmptyLines


<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.798>()

Specifies whether empty lines between records are ignored


when parsing input.

Returns:
|true| if empty lines between records are ignored,
|false| if they are turned into empty records.

getIgnoreHeaderCase

public boolean getIgnoreHeaderCase


<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.808>()

Specifies whether header names will be accessed ignoring case.

Returns:
|true| if header names cases are ignored, |false| if
they are case sensitive.
Since:
1.3

getIgnoreSurroundingSpaces

public boolean getIgnoreSurroundingSpaces


<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.817>()

Specifies whether spaces around values are ignored when


parsing input.

Returns:
|true| if spaces around values are ignored, |false| if
they are treated as part of the value.

getNullString

public String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true>
getNullString <https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.831>()

Gets the String to convert to and from |null|.


# *Reading:* Converts strings equal to the given
|nullString| to |null| when reading records.
# *Writing:* Writes |null| as the given |nullString| when
writing records.

Returns:
the String to convert to and from |null|. No
substitution occurs if |null|

getQuoteCharacter

public Character
<http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html?is-
external=true> getQuoteCharacter <https://commons.apache.org/proper/commons-
csv/apidocs/src-html/org/apache/commons/csv/CSVFormat.html#line.840>()

Returns the character used to encapsulate values containing


special characters.

Returns:
the quoteChar character, may be |null|

+
getQuoteMode

public QuoteMode <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/QuoteMode.html> getQuoteMode
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.849>()

Returns the quote policy output fields.

Returns:
the quote policy

getRecordSeparator

public String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true>
getRecordSeparator <https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.858>()

Returns the record separator delimiting output records.

Returns:
the record separator

getSkipHeaderRecord

public boolean getSkipHeaderRecord


<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.867>()

Returns whether to skip the header record.

Returns:
whether to skip the header record.

getTrailingDelimiter

public boolean getTrailingDelimiter


<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.877>()

Returns whether to add a trailing delimiter.

Returns:
whether to add a trailing delimiter.
Since:
1.3

+
getTrim

public boolean getTrim <https://commons.apache.org/proper/commons-


csv/apidocs/src-html/org/apache/commons/csv/CSVFormat.html#line.886>()

Returns whether to trim leading and trailing blanks.

Returns:
whether to trim leading and trailing blanks.

hashCode

public int hashCode <https://commons.apache.org/proper/commons-


csv/apidocs/src-html/org/apache/commons/csv/CSVFormat.html#line.891>()

Overrides:
|hashCode
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true#hashCode-->| in
class |Object
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true>|

isCommentMarkerSet

public boolean isCommentMarkerSet


<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.917>()

Specifies whether comments are supported by this format.


Note that the comment introducer character is only
recognized at the start of a line.

Returns:
|true| is comments are supported, |false| otherwise

isEscapeCharacterSet

public boolean isEscapeCharacterSet


<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.926>()

Returns whether escape are being processed.

Returns:
|true| if escapes are processed

+
isNullStringSet

public boolean isNullStringSet


<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.935>()

Returns whether a nullString has been defined.

Returns:
|true| if a nullString is defined

isQuoteCharacterSet

public boolean isQuoteCharacterSet


<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.944>()

Returns whether a quoteChar has been defined.

Returns:
|true| if a quoteChar is defined

parse

public CSVParser <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVParser.html> parse
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.961>(Reader
<http://docs.oracle.com/javase/7/docs/api/java/io/Reader.html?is-external=true> in)
throws IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-
external=true>

Parses the specified content.

See also the various static parse methods on |CSVParser|


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVParser.html>.

Parameters:
|in| - the input stream
Returns:
a parser over a stream of |CSVRecord|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVRecord.html>s.
Throws:
|IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?
is-external=true>|
- If an I/O error occurs
+

print

public CSVPrinter <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVPrinter.html> print
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.978>(Appendable
<http://docs.oracle.com/javase/7/docs/api/java/lang/Appendable.html?is-
external=true> out)
throws IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-
external=true>

Prints to the specified output.

See also |CSVPrinter|


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVPrinter.html>.

Parameters:
|out| - the output.
Returns:
a printer to an output.
Throws:
|IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?
is-external=true>|
- thrown if the optional header cannot be printed.

printer

public CSVPrinter <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVPrinter.html> printer
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.994>()
throws IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-
external=true>

Prints to the |System.out|


<http://docs.oracle.com/javase/7/docs/api/java/lang/System.html?is-
external=true#out>.

See also |CSVPrinter|


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVPrinter.html>.

Returns:
a printer to |System.out|
<http://docs.oracle.com/javase/7/docs/api/java/lang/System.html?is-
external=true#out>.
Throws:
|IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?
is-external=true>|
- thrown if the optional header cannot be printed.
Since:
1.5

print

public CSVPrinter <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVPrinter.html> print
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1015>(File
<http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true> out,
Charset
<http://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html?is-
external=true> charset)
throws IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-
external=true>

Prints to the specified output.

See also |CSVPrinter|


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVPrinter.html>.

Parameters:
|out| - the output.
|charset| - A charset.
Returns:
a printer to an output.
Throws:
|IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?
is-external=true>|
- thrown if the optional header cannot be printed.
Since:
1.5

print

public CSVPrinter <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVPrinter.html> print
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1036>(Path
<http://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html?is-external=true>
out,
Charset
<http://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html?is-
external=true> charset)
throws IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-
external=true>

Prints to the specified output.

See also |CSVPrinter|


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVPrinter.html>.

Parameters:
|out| - the output.
|charset| - A charset.
Returns:
a printer to an output.
Throws:
|IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?
is-external=true>|
- thrown if the optional header cannot be printed.
Since:
1.5

print

public void print <https://commons.apache.org/proper/commons-


csv/apidocs/src-html/org/apache/commons/csv/CSVFormat.html#line.1054>(Object
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true>
value,
Appendable
<http://docs.oracle.com/javase/7/docs/api/java/lang/Appendable.html?is-
external=true> out,
boolean newRecord)
throws IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-
external=true>

Prints the |value| as the next value on the line to |out|.


The value will be escaped or encapsulated as needed. Useful
when one wants to avoid creating CSVPrinters.

Parameters:
|value| - value to output.
|out| - where to print the value.
|newRecord| - if this a new record.
Throws:
|IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?
is-external=true>|
- If an I/O error occurs.
Since:
1.4

+
println

public void println <https://commons.apache.org/proper/commons-


csv/apidocs/src-html/org/apache/commons/csv/CSVFormat.html#line.1254>(Appendable
<http://docs.oracle.com/javase/7/docs/api/java/lang/Appendable.html?is-
external=true> out)
throws IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-
external=true>

Outputs the trailing delimiter (if set) followed by the


record separator (if set).

Parameters:
|out| - where to write
Throws:
|IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?
is-external=true>|
- If an I/O error occurs
Since:
1.4

printRecord

public void printRecord <https://commons.apache.org/proper/commons-


csv/apidocs/src-html/org/apache/commons/csv/CSVFormat.html#line.1280>(Appendable
<http://docs.oracle.com/javase/7/docs/api/java/lang/Appendable.html?is-
external=true> out,
Object
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true>... values)
throws IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-
external=true>

Prints the given |values| to |out| as a single record of


delimiter separated values followed by the record separator.

The values will be quoted if needed. Quotes and new-line


characters will be escaped. This method adds the record
separator to the output after printing the record, so there
is no need to call |println(Appendable)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#println-java.lang.Appendable->.

Parameters:
|out| - where to write.
|values| - values to output.
Throws:
|IOException
<http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?
is-external=true>|
- If an I/O error occurs.
Since:
1.4

toString

public String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true>
toString <https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1288>()

Overrides:
|toString
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true#toString-->| in
class |Object
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true>|

withAllowMissingColumnNames

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withAllowMissingColumnNames
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1419>()

Returns a new |CSVFormat| with the missing column names


behavior of the format set to |true|

Returns:
A new CSVFormat that is equal to this but with the
specified missing column names behavior.
Since:
1.1
See Also:
|withAllowMissingColumnNames(boolean)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withAllowMissingColumnNames-
boolean->

withAllowMissingColumnNames

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withAllowMissingColumnNames
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1431>(boolean
allowMissingColumnNames)

Returns a new |CSVFormat| with the missing column names


behavior of the format set to the given value.
Parameters:
|allowMissingColumnNames| - the missing column names
behavior, |true| to allow missing column names in the
header line, |false| to cause an
|IllegalArgumentException|

<http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?
is-external=true>
to be thrown.
Returns:
A new CSVFormat that is equal to this but with the
specified missing column names behavior.

withCommentMarker

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withCommentMarker
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1448>(char commentMarker)

Returns a new |CSVFormat| with the comment start marker of


the format set to the specified character. Note that the
comment start character is only recognized at the start of a
line.

Parameters:
|commentMarker| - the comment start marker
Returns:
A new CSVFormat that is equal to this one but with the
specified character as the comment start marker
Throws:
|IllegalArgumentException

<http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?
is-external=true>|
- thrown if the specified character is a line break

withCommentMarker

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withCommentMarker
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1463>(Character
<http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html?is-
external=true> commentMarker)

Returns a new |CSVFormat| with the comment start marker of


the format set to the specified character. Note that the
comment start character is only recognized at the start of a
line.

Parameters:
|commentMarker| - the comment start marker, use |null|
to disable
Returns:
A new CSVFormat that is equal to this one but with the
specified character as the comment start marker
Throws:
|IllegalArgumentException

<http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?
is-external=true>|
- thrown if the specified character is a line break

withDelimiter

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withDelimiter
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1481>(char delimiter)

Returns a new |CSVFormat| with the delimiter of the format


set to the specified character.

Parameters:
|delimiter| - the delimiter character
Returns:
A new CSVFormat that is equal to this with the specified
character as delimiter
Throws:
|IllegalArgumentException

<http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?
is-external=true>|
- thrown if the specified character is a line break

withEscape

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withEscape
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1499>(char escape)

Returns a new |CSVFormat| with the escape character of the


format set to the specified character.

Parameters:
|escape| - the escape character
Returns:
A new CSVFormat that is equal to his but with the
specified character as the escape character
Throws:
|IllegalArgumentException

<http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?
is-external=true>|
- thrown if the specified character is a line break

withEscape

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withEscape
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1512>(Character
<http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html?is-
external=true> escape)

Returns a new |CSVFormat| with the escape character of the


format set to the specified character.

Parameters:
|escape| - the escape character, use |null| to disable
Returns:
A new CSVFormat that is equal to this but with the
specified character as the escape character
Throws:
|IllegalArgumentException

<http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?
is-external=true>|
- thrown if the specified character is a line break

withFirstRecordAsHeader

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withFirstRecordAsHeader
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1537>()

Returns a new |CSVFormat| using the first record as header.

Calling this method is equivalent to calling:

CSVFormat format = aFormat.withHeader().withSkipHeaderRecord();

Returns:
A new CSVFormat that is equal to this but using the
first record as header.
Since:
1.3
See Also:
|withSkipHeaderRecord(boolean)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withSkipHeaderRecord-boolean->,
|withHeader(String...)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withHeader-java.lang.String...->
+

withHeader

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withHeader
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1567>(Class
<http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html?is-external=true><?
extends Enum <http://docs.oracle.com/javase/7/docs/api/java/lang/Enum.html?is-
external=true><?>> headerEnum)

Returns a new |CSVFormat| with the header of the format


defined by the enum class.

Example:

public enum Header {


Name, Email, Phone
}

CSVFormat format = aformat.withHeader(Header.class);

The header is also used by the |CSVPrinter|


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVPrinter.html>.

Parameters:
|headerEnum| - the enum defining the header, |null| if
disabled, empty if parsed automatically, user specified
otherwise.
Returns:
A new CSVFormat that is equal to this but with the
specified header
Since:
1.3
See Also:
|withHeader(String...)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withHeader-java.lang.String...->,
|withSkipHeaderRecord(boolean)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withSkipHeaderRecord-boolean->

withHeader

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withHeader
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1605>(ResultSet
<http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.html?is-external=true>
resultSet)
throws SQLException
<http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.html?is-
external=true>

Returns a new |CSVFormat| with the header of the format set


from the result set metadata. The header can either be
parsed automatically from the input file with:

CSVFormat format = aformat.withHeader();

or specified manually with:

CSVFormat format = aformat.withHeader(resultSet);

The header is also used by the |CSVPrinter|


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVPrinter.html>.

Parameters:
|resultSet| - the resultSet for the header, |null| if
disabled, empty if parsed automatically, user specified
otherwise.
Returns:
A new CSVFormat that is equal to this but with the
specified header
Throws:
|SQLException

<http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.html?is-
external=true>|
- SQLException if a database access error occurs or this
method is called on a closed result set.
Since:
1.1

withHeader

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withHeader
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1635>(ResultSetMetaData
<http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSetMetaData.html?is-
external=true> metaData)
throws SQLException
<http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.html?is-
external=true>

Returns a new |CSVFormat| with the header of the format set


from the result set metadata. The header can either be
parsed automatically from the input file with:

CSVFormat format = aformat.withHeader();


or specified manually with:

CSVFormat format = aformat.withHeader(metaData);

The header is also used by the |CSVPrinter|


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVPrinter.html>.

Parameters:
|metaData| - the metaData for the header, |null| if
disabled, empty if parsed automatically, user specified
otherwise.
Returns:
A new CSVFormat that is equal to this but with the
specified header
Throws:
|SQLException

<http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.html?is-
external=true>|
- SQLException if a database access error occurs or this
method is called on a closed result set.
Since:
1.1

withHeader

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withHeader
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1670>(String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-
external=true>... header)

Returns a new |CSVFormat| with the header of the format set


to the given values. The header can either be parsed
automatically from the input file with:

CSVFormat format = aformat.withHeader();

or specified manually with:

CSVFormat format = aformat.withHeader("name", "email", "phone");

The header is also used by the |CSVPrinter|


<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVPrinter.html>.

Parameters:
|header| - the header, |null| if disabled, empty if
parsed automatically, user specified otherwise.
Returns:
A new CSVFormat that is equal to this but with the
specified header
See Also:
|withSkipHeaderRecord(boolean)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withSkipHeaderRecord-boolean->

withHeaderComments

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withHeaderComments
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1691>(Object
<http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-
external=true>... headerComments)

Returns a new |CSVFormat| with the header comments of the


format set to the given values. The comments will be printed
first, before the headers. This setting is ignored by the
parser.

CSVFormat format = aformat.withHeaderComments("Generated by Apache


Commons CSV 1.1.", new Date());

Parameters:
|headerComments| - the headerComments which will be
printed by the Printer before the actual CSV data.
Returns:
A new CSVFormat that is equal to this but with the
specified header
Since:
1.1
See Also:
|withSkipHeaderRecord(boolean)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withSkipHeaderRecord-boolean->

withIgnoreEmptyLines

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withIgnoreEmptyLines
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1704>()

Returns a new |CSVFormat| with the empty line skipping


behavior of the format set to |true|.

Returns:
A new CSVFormat that is equal to this but with the
specified empty line skipping behavior.
Since:
|withIgnoreEmptyLines(boolean)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withIgnoreEmptyLines-boolean->,
1.1

withIgnoreEmptyLines

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withIgnoreEmptyLines
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1716>(boolean ignoreEmptyLines)

Returns a new |CSVFormat| with the empty line skipping


behavior of the format set to the given value.

Parameters:
|ignoreEmptyLines| - the empty line skipping behavior,
|true| to ignore the empty lines between the records,
|false| to translate empty lines to empty records.
Returns:
A new CSVFormat that is equal to this but with the
specified empty line skipping behavior.

withIgnoreHeaderCase

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withIgnoreHeaderCase
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1729>()

Returns a new |CSVFormat| with the header ignore case


behavior set to |true|.

Returns:
A new CSVFormat that will ignore case header name.
Since:
1.3
See Also:
|withIgnoreHeaderCase(boolean)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withIgnoreHeaderCase-boolean->

withIgnoreHeaderCase

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withIgnoreHeaderCase
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1742>(boolean ignoreHeaderCase)
Returns a new |CSVFormat| with whether header names should
be accessed ignoring case.

Parameters:
|ignoreHeaderCase| - the case mapping behavior, |true|
to access name/values, |false| to leave the mapping as is.
Returns:
A new CSVFormat that will ignore case header name if
specified as |true|
Since:
1.3

withIgnoreSurroundingSpaces

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withIgnoreSurroundingSpaces
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1755>()

Returns a new |CSVFormat| with the trimming behavior of the


format set to |true|.

Returns:
A new CSVFormat that is equal to this but with the
specified trimming behavior.
Since:
1.1
See Also:
|withIgnoreSurroundingSpaces(boolean)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withIgnoreSurroundingSpaces-
boolean->

withIgnoreSurroundingSpaces

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withIgnoreSurroundingSpaces
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1767>(boolean
ignoreSurroundingSpaces)

Returns a new |CSVFormat| with the trimming behavior of the


format set to the given value.

Parameters:
|ignoreSurroundingSpaces| - the trimming behavior,
|true| to remove the surrounding spaces, |false| to
leave the spaces as is.
Returns:
A new CSVFormat that is equal to this but with the
specified trimming behavior.

+
withNullString

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withNullString
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1786>(String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true>
nullString)

Returns a new |CSVFormat| with conversions to and from null


for strings on input and output.
# *Reading:* Converts strings equal to the given
|nullString| to |null| when reading records.
# *Writing:* Writes |null| as the given |nullString| when
writing records.

Parameters:
|nullString| - the String to convert to and from |null|.
No substitution occurs if |null|
Returns:
A new CSVFormat that is equal to this but with the
specified null conversion string.

withQuote

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withQuote
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1801>(char quoteChar)

Returns a new |CSVFormat| with the quoteChar of the format


set to the specified character.

Parameters:
|quoteChar| - the quoteChar character
Returns:
A new CSVFormat that is equal to this but with the
specified character as quoteChar
Throws:
|IllegalArgumentException

<http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?
is-external=true>|
- thrown if the specified character is a line break

withQuote

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withQuote
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1814>(Character
<http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html?is-
external=true> quoteChar)

Returns a new |CSVFormat| with the quoteChar of the format


set to the specified character.

Parameters:
|quoteChar| - the quoteChar character, use |null| to disable
Returns:
A new CSVFormat that is equal to this but with the
specified character as quoteChar
Throws:
|IllegalArgumentException

<http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?
is-external=true>|
- thrown if the specified character is a line break

withQuoteMode

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withQuoteMode
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1831>(QuoteMode
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/QuoteMode.html> quoteModePolicy)

Returns a new |CSVFormat| with the output quote policy of


the format set to the specified value.

Parameters:
|quoteModePolicy| - the quote policy to use for output.
Returns:
A new CSVFormat that is equal to this but with the
specified quote policy

withRecordSeparator

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withRecordSeparator
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1850>(char recordSeparator)

Returns a new |CSVFormat| with the record separator of the


format set to the specified character.

*Note:* This setting is only used during printing and does


not affect parsing. Parsing currently only works for inputs
with '\n', '\r' and "\r\n"

Parameters:
|recordSeparator| - the record separator to use for output.
Returns:
A new CSVFormat that is equal to this but with the the
specified output record separator

withRecordSeparator

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withRecordSeparator
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1869>(String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true>
recordSeparator)

Returns a new |CSVFormat| with the record separator of the


format set to the specified String.

*Note:* This setting is only used during printing and does


not affect parsing. Parsing currently only works for inputs
with '\n', '\r' and "\r\n"

Parameters:
|recordSeparator| - the record separator to use for output.
Returns:
A new CSVFormat that is equal to this but with the the
specified output record separator
Throws:
|IllegalArgumentException

<http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?
is-external=true>|
- if recordSeparator is none of CR, LF or CRLF

withSkipHeaderRecord

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withSkipHeaderRecord
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1883>()

Returns a new |CSVFormat| with skipping the header record


set to |true|.

Returns:
A new CSVFormat that is equal to this but with the the
specified skipHeaderRecord setting.
Since:
1.1
See Also:
|withSkipHeaderRecord(boolean)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withSkipHeaderRecord-boolean->,
|withHeader(String...)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withHeader-java.lang.String...->
+

withSkipHeaderRecord

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withSkipHeaderRecord
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1896>(boolean skipHeaderRecord)

Returns a new |CSVFormat| with whether to skip the header


record.

Parameters:
|skipHeaderRecord| - whether to skip the header record.
Returns:
A new CSVFormat that is equal to this but with the the
specified skipHeaderRecord setting.
See Also:
|withHeader(String...)|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#withHeader-java.lang.String...->

withTrailingDelimiter

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withTrailingDelimiter
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1908>()

Returns a new |CSVFormat| to add a trailing delimiter.

Returns:
A new CSVFormat that is equal to this but with the
trailing delimiter setting.
Since:
1.3

withTrailingDelimiter

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withTrailingDelimiter
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1921>(boolean trailingDelimiter)

Returns a new |CSVFormat| with whether to add a trailing


delimiter.

Parameters:
|trailingDelimiter| - whether to add a trailing delimiter.
Returns:
A new CSVFormat that is equal to this but with the
specified trailing delimiter setting.
Since:
1.3

withTrim

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withTrim
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1933>()

Returns a new |CSVFormat| to trim leading and trailing blanks.

Returns:
A new CSVFormat that is equal to this but with the trim
setting on.
Since:
1.3

withTrim

public CSVFormat <https://commons.apache.org/proper/commons-


csv/apidocs/org/apache/commons/csv/CSVFormat.html> withTrim
<https://commons.apache.org/proper/commons-csv/apidocs/src-
html/org/apache/commons/csv/CSVFormat.html#line.1946>(boolean trim)

Returns a new |CSVFormat| with whether to trim leading and


trailing blanks.

Parameters:
|trim| - whether to trim leading and trailing blanks.
Returns:
A new CSVFormat that is equal to this but with the
specified trim setting.
Since:
1.3

Skip navigation links <#skip.navbar.bottom>

* Package
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/package-summary.html>
* Class
* Use
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/class-use/CSVFormat.html>
* Tree
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/package-tree.html>
* Deprecated
<https://commons.apache.org/proper/commons-csv/apidocs/deprecated-list.html>
* Index
<https://commons.apache.org/proper/commons-csv/apidocs/index-all.html>
* Help
<https://commons.apache.org/proper/commons-csv/apidocs/help-doc.html>

* Prev Class
* Next Class
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html>

* Frames
<https://commons.apache.org/proper/commons-csv/apidocs/index.html?
org/apache/commons/csv/CSVFormat.html>
* No Frames
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html>

* All Classes
<https://commons.apache.org/proper/commons-csv/apidocs/allclasses-noframe.html>

* Summary:
* Nested <#nested.class.summary> |
* Field <#field.summary> |
* Constr |
* Method <#method.summary>

* Detail:
* Field <#field.detail> |
* Constr |
* Method <#method.detail>

Copyright © 2017 The Apache Software Foundation


<https://www.apache.org/>. All rights reserved.

You might also like