Skip to content

Commit ba016bd

Browse files
committed
Javadoc.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1461213 13f79535-47bb-0310-9956-ffa450edef68
1 parent df08aca commit ba016bd

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

src/main/java/org/apache/commons/csv/CSVParser.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,40 @@
3636
* specification of a {@link CSVFormat}.
3737
*
3838
* <p>
39-
* Parsing of a csv-string having tabs as separators, '"' as an optional value encapsulator, and comments starting with
40-
* '#':
39+
* To parse a CSV input with tabs as separators, '"' (double-quote) as an optional value encapsulator,
40+
* and comments starting with '#', you write:
4141
* </p>
4242
*
4343
* <pre>
44-
* CSVFormat format = new CSVFormat('\t', '&quot;', '#');
4544
* Reader in = new StringReader(&quot;a\tb\nc\td&quot;);
46-
* List&lt;CSVRecord&gt; records = new CSVParser(in, format).getRecords();
45+
* Iterable&lt;CSVRecord&gt; parser = CSVFormat.newBuilder()
46+
* .withCommentStart('#')
47+
* .withDelimiter('\t')
48+
* .withQuoteChar('"').parse(in);
49+
* for (CSVRecord csvRecord : parse) {
50+
* ...
51+
* }
4752
* </pre>
4853
*
4954
* <p>
50-
* Parsing of a csv-string in Excel CSV format, using a for-each loop:
55+
* To parse CSV input in a given format like Excel, you write:
5156
* </p>
5257
*
5358
* <pre>
5459
* Reader in = new StringReader("a;b\nc;d");
55-
* CSVParser parser = new CSVParser(in, CSVFormat.EXCEL);
60+
* Iterable&lt;CSVRecord&gt; parser = CSVFormat.EXCEL.parse(in);
5661
* for (CSVRecord record : parser) {
5762
* ...
5863
* }
5964
* </pre>
60-
*
65+
* <p>
66+
* You may also get a List of records:
67+
* </p>
68+
* <pre>
69+
* Reader in = new StringReader("a;b\nc;d");
70+
* CSVParser parser = new CSVParser(in, CSVFormat.EXCEL);
71+
* List&lt;CSVRecord&gt; list = parser.getRecords();
72+
* </pre>
6173
* <p>
6274
* Internal parser state is completely covered by the format and the reader-state.
6375
* </p>

0 commit comments

Comments
 (0)