public class CSVLine extends ArrayList<String>
If you pass a String, it will be split into several columns which are delimited by the delim character. It will take care for proper unquoting if a column was quoted.
You can also add and remove columns at will. The toString() method will result
in a valid CSV line that can be written out.
The CSV format is: Each row ends with a newline. A row consists of one or more columns, each separated by a delimiter character. If one column contains the delimiter character, the entire column must be quoted in double quotes. If the column also contains the quote character, then the quote characters within the column must be doubled.
CSVLine inherits the List interface for easier access.
modCount| Constructor and Description |
|---|
CSVLine()
Creates a new, empty CSVLine with ';' as delimiter.
|
CSVLine(char delim)
Creates a new, empty CSVLine with the given delimiter.
|
CSVLine(String text)
Creates a new CSVLine, with the given text and ';' as default delimiter.
|
CSVLine(String text,
char delim)
Creates a new CSVLine with the given text and the given delimiter.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLine(String text)
Adds a CSV line to the current content.
|
char |
getDelimiter()
Gets the delimiter character.
|
void |
setDelimiter(char delim)
Sets the delimiter character.
|
String |
toString()
Gets a valid CSV line of the current content, using the current delimiter char.
|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeequals, hashCodecontainsAllfinalize, getClass, notify, notifyAll, wait, wait, waitcontainsAll, equals, hashCodeparallelStream, streampublic CSVLine()
public CSVLine(char delim)
delim - Delimiterpublic CSVLine(String text)
text - Text to be split uppublic void addLine(String text)
If you want to use this class with a new line, use ArrayList.clear() before:
csvline.clear(); csvline.addLine(line);
text - Line to be addedpublic void setDelimiter(char delim)
delim - Delimiterpublic char getDelimiter()
public String toString()
Note: There is no newline character at the end of the line!
toString in class AbstractCollection<String>Copyright © 2004–2016. All rights reserved.