|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.commons.csv.CSVFormat
public class CSVFormat
Specifies the format of a CSV file and parses input.
This class is immutable.
You can extend a format through a builder. For example, to extend the Excel format with columns header, you write:CSVFormat.EXCEL.toBuilder().withHeader("Col1", "Col2", "Col3").build();
You can parse through a format. For example, to parse an Excel file with columns header, you write:
Reader in = ...;
CSVFormat.EXCEL.toBuilder().withHeader("Col1", "Col2", "Col3").parse(in);
| Nested Class Summary | |
|---|---|
static class |
CSVFormat.CSVFormatBuilder
Builds CSVFormat objects. |
| Field Summary | |
|---|---|
static CSVFormat |
DEFAULT
Standard comma separated format, as for RFC4180 but allowing empty lines. |
static CSVFormat |
EXCEL
Excel file format (using a comma as the value delimiter). |
static CSVFormat |
MYSQL
Default MySQL format used by the SELECT INTO OUTFILE and LOAD DATA INFILE operations. |
static CSVFormat |
RFC4180
Comma separated format as defined by RFC 4180. |
static CSVFormat |
TDF
Tab-delimited format, with quote; leading and trailing spaces ignored. |
| Method Summary | |
|---|---|
boolean |
equals(Object obj)
|
String |
format(Object... values)
Formats the specified values. |
Character |
getCommentStart()
Returns the character marking the start of a line comment. |
char |
getDelimiter()
Returns the character delimiting the values (typically ';', ',' or '\t'). |
Character |
getEscape()
Returns the escape character. |
boolean |
getIgnoreEmptyLines()
Specifies whether empty lines between records are ignored when parsing input. |
boolean |
getIgnoreSurroundingSpaces()
Specifies whether spaces around values are ignored when parsing input. |
Character |
getQuoteChar()
Returns the character used to encapsulate values containing special characters. |
Quote |
getQuotePolicy()
Returns the quote policy output fields. |
String |
getRecordSeparator()
Returns the line separator delimiting output records. |
int |
hashCode()
|
boolean |
isCommentingEnabled()
Specifies whether comments are supported by this format. |
boolean |
isEscaping()
Returns whether escape are being processed. |
boolean |
isQuoting()
Returns whether an quoteChar has been defined. |
static CSVFormat.CSVFormatBuilder |
newBuilder()
Creates a standard comma separated format builder, as for RFC4180 but allowing empty lines. |
static CSVFormat.CSVFormatBuilder |
newBuilder(char delimiter)
Creates a new CSV format builder. |
static CSVFormat.CSVFormatBuilder |
newBuilder(CSVFormat format)
Creates a CSVFormatBuilder, using the values of the given CSVFormat. |
Iterable<CSVRecord> |
parse(Reader in)
Parses the specified content. |
CSVFormat.CSVFormatBuilder |
toBuilder()
Creates a builder based on this format. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final CSVFormat RFC4180
public static final CSVFormat DEFAULT
RFC4180 but allowing empty lines.
public static final CSVFormat EXCEL
CSVFormat fmt = CSVFormat.newBuilder(EXCEL).withDelimiter(';').build();
Settings are:
public static final CSVFormat TDF
public static final CSVFormat MYSQL
| Method Detail |
|---|
public static CSVFormat.CSVFormatBuilder newBuilder(char delimiter)
delimiter - the char used for value separation, must not be a line break character
IllegalArgumentException - if the delimiter is a line break characterpublic static CSVFormat.CSVFormatBuilder newBuilder(CSVFormat format)
format - The format to use values from
public static CSVFormat.CSVFormatBuilder newBuilder()
RFC4180 but allowing empty lines.
CSVFormat.newBuilder(CSVFormat.DEFAULT)
RFC4180 but allowing empty lines.public char getDelimiter()
public Character getQuoteChar()
public boolean isQuoting()
true if an quoteChar is definedpublic Character getCommentStart()
public boolean isCommentingEnabled()
public Character getEscape()
public boolean isEscaping()
true if escapes are processedpublic boolean getIgnoreSurroundingSpaces()
public boolean getIgnoreEmptyLines()
public String getRecordSeparator()
public Iterable<CSVRecord> parse(Reader in)
throws IOException
in - the input stream
IOException - If an I/O error occurspublic String format(Object... values)
values - the values to format
public String toString()
toString in class Objectpublic Quote getQuotePolicy()
public int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Objectpublic CSVFormat.CSVFormatBuilder toBuilder()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||