Professional Documents
Culture Documents
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
------------------------------------------------------------------------
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:
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:
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:
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
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>.
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:
Notes
See Also:
Serialized Form
<https://commons.apache.org/proper/commons-csv/apidocs/serialized-
form.html#org.apache.commons.csv.CSVFormat>
*
o
Predefines formats.
Field Summary
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>|
Tab-delimited format.
Method Summary
|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)|
|boolean| |isCommentMarkerSet
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.html#isCommentMarkerSet-->()|
|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)|
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)|
|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
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
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->
See Also:
|CSVFormat.Predefined.Excel|
<https://commons.apache.org/proper/commons-
csv/apidocs/org/apache/commons/csv/CSVFormat.Predefined.html#Excel>
INFORMIX_UNLOAD
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
# 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
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>
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
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
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
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
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
Parameters:
|format| - name
Returns:
one of the predefined formats
Since:
1.2
equals
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)
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>()
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 comment start marker, may be |null|
getDelimiter
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, 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; |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; |null| if disabled.
getIgnoreEmptyLines
Returns:
|true| if empty lines between records are ignored,
|false| if they are turned into empty records.
getIgnoreHeaderCase
Returns:
|true| if header names cases are ignored, |false| if
they are case sensitive.
Since:
1.3
getIgnoreSurroundingSpaces
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>()
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 quoteChar character, may be |null|
+
getQuoteMode
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
getSkipHeaderRecord
Returns:
whether to skip the header record.
getTrailingDelimiter
Returns:
whether to add a trailing delimiter.
Since:
1.3
+
getTrim
Returns:
whether to trim leading and trailing blanks.
hashCode
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
Returns:
|true| is comments are supported, |false| otherwise
isEscapeCharacterSet
Returns:
|true| if escapes are processed
+
isNullStringSet
Returns:
|true| if a nullString is defined
isQuoteCharacterSet
Returns:
|true| if a quoteChar is defined
parse
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
+
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
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
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
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
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
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
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
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
<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
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
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
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
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
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
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
Example:
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Returns:
A new CSVFormat that is equal to this but with the
trailing delimiter setting.
Since:
1.3
withTrailingDelimiter
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
Returns:
A new CSVFormat that is equal to this but with the trim
setting on.
Since:
1.3
withTrim
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
* 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>