public final class CSVFormat extends Object implements Serializable
You can use one of the predefined formats:
DEFAULT
EXCEL
INFORMIX_UNLOAD
INFORMIX_UNLOAD_CSV
MYSQL
RFC4180
ORACLE
POSTGRESQL_CSV
POSTGRESQL_TEXT
TDF
For example:
CSVParser parser = CSVFormat.EXCEL.parse(reader);
The CSVParser
provides static methods to parse other input types, for example:
CSVParser parser = CSVParser.parse(file, StandardCharsets.US_ASCII, CSVFormat.EXCEL);
You can extend a format by calling the set
methods. For example:
CSVFormat.EXCEL.withNullString("N/A").withIgnoreSurroundingSpaces(true);
To define the column names you want to use to access records, write:
CSVFormat.EXCEL.withHeader("Col1", "Col2", "Col3");
Calling CSVFormat.Builder.setHeader(String...)
lets you use the given names to address values in a CSVRecord
, 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
CSVFormat.Builder.setSkipHeaderRecord(boolean)
with true
.
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
.
If your source contains a header record, you can simplify your code and safely reference columns, by using CSVFormat.Builder.setHeader(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
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.
This class implements the Serializable
interface with the following caveats:
The serialVersionUID
values are:
2L
1L
This class is immutable.
Not all settings are used for both parsing and writing.
Modifier and Type | Class and Description |
---|---|
static class |
CSVFormat.Builder
Builds CSVFormat instances.
|
static class |
CSVFormat.Predefined
Predefines formats.
|
Modifier and Type | Field and Description |
---|---|
static CSVFormat |
DEFAULT
Standard Comma Separated Value format, as for
RFC4180 but allowing
empty lines. |
static CSVFormat |
EXCEL
Excel file format (using a comma as the value delimiter).
|
static CSVFormat |
INFORMIX_UNLOAD
Default Informix CSV UNLOAD format used by the
UNLOAD TO file_name operation. |
static CSVFormat |
INFORMIX_UNLOAD_CSV
Default Informix CSV UNLOAD format used by the
UNLOAD TO file_name operation (escaping is disabled.) |
static CSVFormat |
MONGODB_CSV
Default MongoDB CSV format used by the
mongoexport operation. |
static CSVFormat |
MONGODB_TSV
Default MongoDB TSV format used by the
mongoexport operation. |
static CSVFormat |
MYSQL
Default MySQL format used by the
SELECT INTO OUTFILE and LOAD DATA INFILE operations. |
static CSVFormat |
ORACLE
Default Oracle format used by the SQL*Loader utility.
|
static CSVFormat |
POSTGRESQL_CSV
Default PostgreSQL CSV format used by the
COPY operation. |
static CSVFormat |
POSTGRESQL_TEXT
Default PostgreSQL text format used by the
COPY operation. |
static CSVFormat |
RFC4180
Comma separated format as defined by RFC 4180.
|
static CSVFormat |
TDF
Tab-delimited format.
|
Modifier and Type | Method and Description |
---|---|
CSVFormat.Builder |
builder()
Creates a new Builder for this instance.
|
boolean |
equals(Object obj) |
String |
format(Object... values)
Formats the specified values.
|
boolean |
getAllowDuplicateHeaderNames()
Deprecated.
|
boolean |
getAllowMissingColumnNames()
Gets whether missing column names are allowed when parsing the header line.
|
boolean |
getAutoFlush()
Gets whether to flush on close.
|
Character |
getCommentMarker()
Gets the character marking the start of a line comment.
|
char |
getDelimiter()
Deprecated.
Use
getDelimiterString() . |
String |
getDelimiterString()
Gets the character delimiting the values (typically ";", "," or "\t").
|
DuplicateHeaderMode |
getDuplicateHeaderMode()
Gets how duplicate headers are handled.
|
Character |
getEscapeCharacter()
Gets the escape character.
|
String[] |
getHeader()
Gets a copy of the header array.
|
String[] |
getHeaderComments()
Gets a copy of the header comment array.
|
boolean |
getIgnoreEmptyLines()
Gets whether empty lines between records are ignored when parsing input.
|
boolean |
getIgnoreHeaderCase()
Gets whether header names will be accessed ignoring case when parsing input.
|
boolean |
getIgnoreSurroundingSpaces()
Gets whether spaces around values are ignored when parsing input.
|
String |
getNullString()
Gets the String to convert to and from
null . |
Character |
getQuoteCharacter()
Gets the character used to encapsulate values containing special characters.
|
QuoteMode |
getQuoteMode()
Gets the quote policy output fields.
|
String |
getRecordSeparator()
Gets the record separator delimiting output records.
|
boolean |
getSkipHeaderRecord()
Gets whether to skip the header record.
|
boolean |
getTrailingDelimiter()
Gets whether to add a trailing delimiter.
|
boolean |
getTrim()
Gets whether to trim leading and trailing blanks.
|
int |
hashCode() |
boolean |
isCommentMarkerSet()
Tests whether comments are supported by this format.
|
boolean |
isEscapeCharacterSet()
Tests whether escape are being processed.
|
boolean |
isNullStringSet()
Tests whether a nullString has been defined.
|
boolean |
isQuoteCharacterSet()
Tests whether a quoteChar has been defined.
|
static CSVFormat |
newFormat(char delimiter)
Creates a new CSV format with the specified delimiter.
|
CSVParser |
parse(Reader reader)
Parses the specified content.
|
CSVPrinter |
print(Appendable out)
Prints to the specified output.
|
CSVPrinter |
print(File out,
Charset charset)
Prints to the specified output.
|
void |
print(Object value,
Appendable out,
boolean newRecord)
Prints the
value as the next value on the line to out . |
CSVPrinter |
print(Path out,
Charset charset)
Prints to the specified output, returns a
CSVPrinter which the caller MUST close. |
CSVPrinter |
printer()
Prints to the
System.out . |
void |
println(Appendable appendable)
Outputs the trailing delimiter (if set) followed by the record separator (if set).
|
void |
printRecord(Appendable appendable,
Object... values)
Prints the given
values to out as a single record of delimiter separated values followed by the record separator. |
String |
toString() |
static CSVFormat |
valueOf(String format)
Gets one of the predefined formats from
CSVFormat.Predefined . |
CSVFormat |
withAllowDuplicateHeaderNames()
Deprecated.
|
CSVFormat |
withAllowDuplicateHeaderNames(boolean allowDuplicateHeaderNames)
Deprecated.
|
CSVFormat |
withAllowMissingColumnNames()
Deprecated.
|
CSVFormat |
withAllowMissingColumnNames(boolean allowMissingColumnNames)
Deprecated.
|
CSVFormat |
withAutoFlush(boolean autoFlush)
Deprecated.
|
CSVFormat |
withCommentMarker(char commentMarker)
Deprecated.
|
CSVFormat |
withCommentMarker(Character commentMarker)
Deprecated.
|
CSVFormat |
withDelimiter(char delimiter)
Deprecated.
|
CSVFormat |
withEscape(char escape)
Deprecated.
|
CSVFormat |
withEscape(Character escape)
Deprecated.
|
CSVFormat |
withFirstRecordAsHeader()
Deprecated.
|
CSVFormat |
withHeader(Class<? extends Enum<?>> headerEnum)
Deprecated.
|
CSVFormat |
withHeader(ResultSet resultSet)
Deprecated.
|
CSVFormat |
withHeader(ResultSetMetaData resultSetMetaData)
Deprecated.
|
CSVFormat |
withHeader(String... header)
Deprecated.
|
CSVFormat |
withHeaderComments(Object... headerComments)
Deprecated.
|
CSVFormat |
withIgnoreEmptyLines()
Deprecated.
|
CSVFormat |
withIgnoreEmptyLines(boolean ignoreEmptyLines)
Deprecated.
|
CSVFormat |
withIgnoreHeaderCase()
Deprecated.
|
CSVFormat |
withIgnoreHeaderCase(boolean ignoreHeaderCase)
Deprecated.
|
CSVFormat |
withIgnoreSurroundingSpaces()
Deprecated.
|
CSVFormat |
withIgnoreSurroundingSpaces(boolean ignoreSurroundingSpaces)
Deprecated.
|
CSVFormat |
withNullString(String nullString)
Deprecated.
|
CSVFormat |
withQuote(char quoteChar)
Deprecated.
|
CSVFormat |
withQuote(Character quoteChar)
Deprecated.
|
CSVFormat |
withQuoteMode(QuoteMode quoteMode)
Deprecated.
|
CSVFormat |
withRecordSeparator(char recordSeparator)
Deprecated.
|
CSVFormat |
withRecordSeparator(String recordSeparator)
Deprecated.
|
CSVFormat |
withSkipHeaderRecord()
Deprecated.
|
CSVFormat |
withSkipHeaderRecord(boolean skipHeaderRecord)
Deprecated.
|
CSVFormat |
withSystemRecordSeparator()
Deprecated.
|
CSVFormat |
withTrailingDelimiter()
Deprecated.
|
CSVFormat |
withTrailingDelimiter(boolean trailingDelimiter)
Deprecated.
|
CSVFormat |
withTrim()
Deprecated.
|
CSVFormat |
withTrim(boolean trim)
Deprecated.
|
public static final CSVFormat DEFAULT
RFC4180
but allowing
empty lines.
The CSVFormat.Builder
settings are:
setDelimiter(',')
setQuote('"')
setRecordSeparator("\r\n")
setIgnoreEmptyLines(true)
setDuplicateHeaderMode(DuplicateHeaderMode.ALLOW_ALL)
CSVFormat.Predefined.Default
public static final CSVFormat EXCEL
For example for parsing or generating a CSV file on a French system the following format will be used:
CSVFormat fmt = CSVFormat.EXCEL.withDelimiter(';');
The CSVFormat.Builder
settings are:
setDelimiter(',')
setQuote('"')
setRecordSeparator("\r\n")
setIgnoreEmptyLines(false)
setAllowMissingColumnNames(true)
setDuplicateHeaderMode(DuplicateHeaderMode.ALLOW_ALL)
Note: This is currently like RFC4180
plus Builder#setAllowMissingColumnNames(true)
and
Builder#setIgnoreEmptyLines(false)
.
CSVFormat.Predefined.Excel
public static final CSVFormat INFORMIX_UNLOAD
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"
.
The CSVFormat.Builder
settings are:
setDelimiter(',')
setEscape('\\')
setQuote("\"")
setRecordSeparator('\n')
public static final CSVFormat INFORMIX_UNLOAD_CSV
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"
.
The CSVFormat.Builder
settings are:
setDelimiter(',')
setQuote("\"")
setRecordSeparator('\n')
public static final CSVFormat MONGODB_CSV
mongoexport
operation.
Parsing is not supported yet.
This is a comma-delimited format. Values are double quoted only if needed and special characters are escaped with '"'
. A header line with field
names is expected.
The CSVFormat.Builder
settings are:
setDelimiter(',')
setEscape('"')
setQuote('"')
setQuoteMode(QuoteMode.ALL_NON_NULL)
setSkipHeaderRecord(false)
CSVFormat.Predefined.MongoDBCsv
,
MongoDB mongoexport command documentationpublic static final CSVFormat MONGODB_TSV
mongoexport
operation.
Parsing is not supported yet.
This is a tab-delimited format. Values are double quoted only if needed and special
characters are escaped with '"'
. A header line with field names is expected.
The CSVFormat.Builder
settings are:
setDelimiter('\t')
setEscape('"')
setQuote('"')
setQuoteMode(QuoteMode.ALL_NON_NULL)
setSkipHeaderRecord(false)
CSVFormat.Predefined.MongoDBCsv
,
MongoDB mongoexport command
documentationpublic static final CSVFormat MYSQL
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"
.
The CSVFormat.Builder
settings are:
setDelimiter('\t')
setEscape('\\')
setIgnoreEmptyLines(false)
setQuote(null)
setRecordSeparator('\n')
setNullString("\\N")
setQuoteMode(QuoteMode.ALL_NON_NULL)
public static final CSVFormat ORACLE
This is a comma-delimited format with the system line separator character as the record separator.Values are
double quoted when needed and special characters are escaped with '"'
. The default NULL string is
""
. Values are trimmed.
The CSVFormat.Builder
settings are:
setDelimiter(',') // default is {@code FIELDS TERMINATED BY ','}
setEscape('\\')
setIgnoreEmptyLines(false)
setQuote('"') // default is {@code OPTIONALLY ENCLOSED BY '"'}
setNullString("\\N")
setTrim()
setSystemRecordSeparator()
setQuoteMode(QuoteMode.MINIMAL)
CSVFormat.Predefined.Oracle
,
Oracle CSV Format Specificationpublic static final CSVFormat POSTGRESQL_CSV
COPY
operation.
This is a comma-delimited format with a LF character as the line separator. Values are double quoted and special
characters are not escaped. The default NULL string is ""
.
The CSVFormat.Builder
settings are:
setDelimiter(',')
setEscape(null)
setIgnoreEmptyLines(false)
setQuote('"')
setRecordSeparator('\n')
setNullString("")
setQuoteMode(QuoteMode.ALL_NON_NULL)
CSVFormat.Predefined.MySQL
,
PostgreSQL COPY command
documentationpublic static final CSVFormat POSTGRESQL_TEXT
COPY
operation.
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"
.
The CSVFormat.Builder
settings are:
setDelimiter('\t')
setEscape('\\')
setIgnoreEmptyLines(false)
setQuote(null)
setRecordSeparator('\n')
setNullString("\\N")
setQuoteMode(QuoteMode.ALL_NON_NULL)
CSVFormat.Predefined.MySQL
,
PostgreSQL COPY command
documentationpublic static final CSVFormat RFC4180
The CSVFormat.Builder
settings are:
setDelimiter(',')
setQuote('"')
setRecordSeparator("\r\n")
setIgnoreEmptyLines(false)
CSVFormat.Predefined.RFC4180
public static final CSVFormat TDF
The CSVFormat.Builder
settings are:
setDelimiter('\t')
setQuote('"')
setRecordSeparator("\r\n")
setIgnoreSurroundingSpaces(true)
CSVFormat.Predefined.TDF
public static CSVFormat newFormat(char delimiter)
Use this method if you want to create a CSVFormat from scratch. All fields but the delimiter will be initialized with null/false.
public static CSVFormat valueOf(String format)
CSVFormat.Predefined
.format
- namepublic CSVFormat.Builder builder()
public String format(Object... values)
values
- the values to format@Deprecated public boolean getAllowDuplicateHeaderNames()
getDuplicateHeaderMode()
.public boolean getAllowMissingColumnNames()
true
if missing column names are allowed when parsing the header line, false
to throw an IllegalArgumentException
.public boolean getAutoFlush()
public Character getCommentMarker()
null
@Deprecated public char getDelimiter()
getDelimiterString()
.public String getDelimiterString()
public DuplicateHeaderMode getDuplicateHeaderMode()
public Character getEscapeCharacter()
null
public String[] getHeader()
null
if disabled, the empty array if to be read from the filepublic String[] getHeaderComments()
null
if disabled.public boolean getIgnoreEmptyLines()
true
if empty lines between records are ignored, false
if they are turned into empty records.public boolean getIgnoreHeaderCase()
true
if header names cases are ignored, false
if they are case sensitive.public boolean getIgnoreSurroundingSpaces()
true
if spaces around values are ignored, false
if they are treated as part of the value.public String getNullString()
null
.
nullString
to null
when reading records.null
as the given nullString
when writing records.null
. No substitution occurs if null
public Character getQuoteCharacter()
null
public QuoteMode getQuoteMode()
public String getRecordSeparator()
public boolean getSkipHeaderRecord()
public boolean getTrailingDelimiter()
public boolean getTrim()
print(Object, Appendable, boolean)
Also by
{CSVParser#addRecordValue(boolean)}public boolean isCommentMarkerSet()
true
is comments are supported, false
otherwisepublic boolean isEscapeCharacterSet()
true
if escapes are processedpublic boolean isNullStringSet()
true
if a nullString is definedpublic boolean isQuoteCharacterSet()
true
if a quoteChar is definedpublic CSVParser parse(Reader reader) throws IOException
See also the various static parse methods on CSVParser
.
reader
- the input streamCSVRecord
s.IOException
- If an I/O error occurspublic CSVPrinter print(Appendable out) throws IOException
See also CSVPrinter
.
out
- the output.IOException
- thrown if the optional header cannot be printed.public CSVPrinter print(File out, Charset charset) throws IOException
See also CSVPrinter
.
out
- the output.charset
- A charset.IOException
- thrown if the optional header cannot be printed.public void print(Object value, Appendable out, boolean newRecord) throws IOException
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. Trims the value if getTrim()
is true.value
- value to output.out
- where to print the value.newRecord
- if this a new record.IOException
- If an I/O error occurs.public CSVPrinter print(Path out, Charset charset) throws IOException
CSVPrinter
which the caller MUST close.
See also CSVPrinter
.
out
- the output.charset
- A charset.IOException
- thrown if the optional header cannot be printed.public CSVPrinter printer() throws IOException
System.out
.
See also CSVPrinter
.
System.out
.IOException
- thrown if the optional header cannot be printed.public void println(Appendable appendable) throws IOException
appendable
- where to writeIOException
- If an I/O error occurs.public void printRecord(Appendable appendable, Object... values) throws IOException
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)
.
appendable
- where to write.values
- values to output.IOException
- If an I/O error occurs.@Deprecated public CSVFormat withAllowDuplicateHeaderNames()
Builder#setAllowDuplicateHeaderNames(true)
CSVFormat
that allows duplicate header names.CSVFormat
that allows duplicate header names@Deprecated public CSVFormat withAllowDuplicateHeaderNames(boolean allowDuplicateHeaderNames)
CSVFormat.Builder.setAllowDuplicateHeaderNames(boolean)
CSVFormat
with duplicate header names behavior set to the given value.allowDuplicateHeaderNames
- the duplicate header names behavior, true to allow, false to disallow.CSVFormat
with duplicate header names behavior set to the given value.@Deprecated public CSVFormat withAllowMissingColumnNames()
Builder#setAllowMissingColumnNames(true)
CSVFormat
with the missing column names behavior of the format set to true
.CSVFormat.Builder.setAllowMissingColumnNames(boolean)
@Deprecated public CSVFormat withAllowMissingColumnNames(boolean allowMissingColumnNames)
CSVFormat.Builder.setAllowMissingColumnNames(boolean)
CSVFormat
with the missing column names behavior of the format set to the given value.allowMissingColumnNames
- the missing column names behavior, true
to allow missing column names in the header line, false
to cause
an IllegalArgumentException
to be thrown.@Deprecated public CSVFormat withAutoFlush(boolean autoFlush)
CSVFormat.Builder.setAutoFlush(boolean)
CSVFormat
with whether to flush on close.autoFlush
- whether to flush on close.@Deprecated public CSVFormat withCommentMarker(char commentMarker)
CSVFormat.Builder.setCommentMarker(char)
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.commentMarker
- the comment start markerIllegalArgumentException
- thrown if the specified character is a line break@Deprecated public CSVFormat withCommentMarker(Character commentMarker)
CSVFormat.Builder.setCommentMarker(Character)
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.commentMarker
- the comment start marker, use null
to disableIllegalArgumentException
- thrown if the specified character is a line break@Deprecated public CSVFormat withDelimiter(char delimiter)
CSVFormat.Builder.setDelimiter(char)
CSVFormat
with the delimiter of the format set to the specified character.delimiter
- the delimiter characterIllegalArgumentException
- thrown if the specified character is a line break@Deprecated public CSVFormat withEscape(char escape)
CSVFormat.Builder.setEscape(char)
CSVFormat
with the escape character of the format set to the specified character.escape
- the escape characterIllegalArgumentException
- thrown if the specified character is a line break@Deprecated public CSVFormat withEscape(Character escape)
CSVFormat.Builder.setEscape(Character)
CSVFormat
with the escape character of the format set to the specified character.escape
- the escape character, use null
to disableIllegalArgumentException
- thrown if the specified character is a line break@Deprecated public CSVFormat withFirstRecordAsHeader()
Builder#setHeader()
.setSkipHeaderRecord(true)
.CSVFormat
using the first record as header.
Calling this method is equivalent to calling:
CSVFormat format = aFormat.withHeader().withSkipHeaderRecord();
CSVFormat.Builder.setSkipHeaderRecord(boolean)
,
CSVFormat.Builder.setHeader(String...)
@Deprecated public CSVFormat withHeader(Class<? extends Enum<?>> headerEnum)
CSVFormat.Builder.setHeader(Class)
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
.
headerEnum
- the enum defining the header, null
if disabled, empty if parsed automatically, user specified otherwise.CSVFormat.Builder.setHeader(String...)
,
CSVFormat.Builder.setSkipHeaderRecord(boolean)
@Deprecated public CSVFormat withHeader(ResultSet resultSet) throws SQLException
CSVFormat.Builder.setHeader(ResultSet)
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
.
resultSet
- the resultSet for the header, null
if disabled, empty if parsed automatically, user specified otherwise.SQLException
- SQLException if a database access error occurs or this method is called on a closed result set.@Deprecated public CSVFormat withHeader(ResultSetMetaData resultSetMetaData) throws SQLException
CSVFormat.Builder.setHeader(ResultSetMetaData)
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
.
resultSetMetaData
- the metaData for the header, null
if disabled, empty if parsed automatically, user specified otherwise.SQLException
- SQLException if a database access error occurs or this method is called on a closed result set.@Deprecated public CSVFormat withHeader(String... header)
CSVFormat.Builder.setHeader(String...)
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
.
header
- the header, null
if disabled, empty if parsed automatically, user specified otherwise.CSVFormat.Builder.setSkipHeaderRecord(boolean)
@Deprecated public CSVFormat withHeaderComments(Object... headerComments)
CSVFormat.Builder.setHeaderComments(Object...)
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.", Instant.now());
headerComments
- the headerComments which will be printed by the Printer before the actual CSV data.CSVFormat.Builder.setSkipHeaderRecord(boolean)
@Deprecated public CSVFormat withIgnoreEmptyLines()
Builder#setIgnoreEmptyLines(true)
CSVFormat
with the empty line skipping behavior of the format set to true
.CSVFormat.Builder.setIgnoreEmptyLines(boolean)
@Deprecated public CSVFormat withIgnoreEmptyLines(boolean ignoreEmptyLines)
CSVFormat.Builder.setIgnoreEmptyLines(boolean)
CSVFormat
with the empty line skipping behavior of the format set to the given value.ignoreEmptyLines
- the empty line skipping behavior, true
to ignore the empty lines between the records, false
to translate empty
lines to empty records.@Deprecated public CSVFormat withIgnoreHeaderCase()
Builder#setIgnoreHeaderCase(true)
CSVFormat
with the header ignore case behavior set to true
.CSVFormat.Builder.setIgnoreHeaderCase(boolean)
@Deprecated public CSVFormat withIgnoreHeaderCase(boolean ignoreHeaderCase)
CSVFormat.Builder.setIgnoreHeaderCase(boolean)
CSVFormat
with whether header names should be accessed ignoring case.ignoreHeaderCase
- the case mapping behavior, true
to access name/values, false
to leave the mapping as is.true
@Deprecated public CSVFormat withIgnoreSurroundingSpaces()
Builder#setIgnoreSurroundingSpaces(true)
CSVFormat
with the parser trimming behavior of the format set to true
.CSVFormat.Builder.setIgnoreSurroundingSpaces(boolean)
@Deprecated public CSVFormat withIgnoreSurroundingSpaces(boolean ignoreSurroundingSpaces)
CSVFormat.Builder.setIgnoreSurroundingSpaces(boolean)
CSVFormat
with the parser trimming behavior of the format set to the given value.ignoreSurroundingSpaces
- the parser trimming behavior, true
to remove the surrounding spaces, false
to leave the spaces as is.@Deprecated public CSVFormat withNullString(String nullString)
CSVFormat.Builder.setNullString(String)
CSVFormat
with conversions to and from null for strings on input and output.
nullString
to null
when reading records.null
as the given nullString
when writing records.nullString
- the String to convert to and from null
. No substitution occurs if null
@Deprecated public CSVFormat withQuote(char quoteChar)
CSVFormat.Builder.setQuote(char)
CSVFormat
with the quoteChar of the format set to the specified character.quoteChar
- the quote characterIllegalArgumentException
- thrown if the specified character is a line break@Deprecated public CSVFormat withQuote(Character quoteChar)
CSVFormat.Builder.setQuote(Character)
CSVFormat
with the quoteChar of the format set to the specified character.quoteChar
- the quote character, use null
to disable.IllegalArgumentException
- thrown if the specified character is a line break@Deprecated public CSVFormat withQuoteMode(QuoteMode quoteMode)
CSVFormat.Builder.setQuoteMode(QuoteMode)
CSVFormat
with the output quote policy of the format set to the specified value.quoteMode
- the quote policy to use for output.@Deprecated public CSVFormat withRecordSeparator(char recordSeparator)
CSVFormat.Builder.setRecordSeparator(char)
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"
recordSeparator
- the record separator to use for output.@Deprecated public CSVFormat withRecordSeparator(String recordSeparator)
CSVFormat.Builder.setRecordSeparator(String)
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"
recordSeparator
- the record separator to use for output.IllegalArgumentException
- if recordSeparator is none of CR, LF or CRLF@Deprecated public CSVFormat withSkipHeaderRecord()
Builder#setSkipHeaderRecord(true)
CSVFormat
with skipping the header record set to true
.CSVFormat.Builder.setSkipHeaderRecord(boolean)
,
CSVFormat.Builder.setHeader(String...)
@Deprecated public CSVFormat withSkipHeaderRecord(boolean skipHeaderRecord)
CSVFormat.Builder.setSkipHeaderRecord(boolean)
CSVFormat
with whether to skip the header record.skipHeaderRecord
- whether to skip the header record.CSVFormat.Builder.setHeader(String...)
@Deprecated public CSVFormat withSystemRecordSeparator()
setRecordSeparator(System.lineSeparator())
CSVFormat
with the record separator of the format set to the operating system's line separator string, typically CR+LF on Windows
and LF on Linux.
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"
@Deprecated public CSVFormat withTrailingDelimiter()
Builder#setTrailingDelimiter(true)
CSVFormat
to add a trailing delimiter.@Deprecated public CSVFormat withTrailingDelimiter(boolean trailingDelimiter)
CSVFormat.Builder.setTrailingDelimiter(boolean)
CSVFormat
with whether to add a trailing delimiter.trailingDelimiter
- whether to add a trailing delimiter.@Deprecated public CSVFormat withTrim()
Builder#setTrim(true)
CSVFormat
to trim leading and trailing blanks. See getTrim()
for details of where this is used.@Deprecated public CSVFormat withTrim(boolean trim)
CSVFormat.Builder.setTrim(boolean)
CSVFormat
with whether to trim leading and trailing blanks. See getTrim()
for details of where this is used.trim
- whether to trim leading and trailing blanks.Copyright © 2005–2022 The Apache Software Foundation. All rights reserved.