You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/java/org/apache/commons/csv/CSVFormat.java
+55-6Lines changed: 55 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -521,12 +521,46 @@ public Builder setHeader(final String... header) {
521
521
}
522
522
523
523
/**
524
-
* Sets the header comments set to the given values. The comments will be printed first with the provided comment marker set by {@link Builder#setCommentMarker(char)}, before the headers. This setting is ignored by the parser.
524
+
* Gets the character marking the start of a line comment.
525
+
* <p>
526
+
* The comment format for each line is:
527
+
* </p>
528
+
* <pre>
529
+
* CommentMarker SPACE CommentArrayElement
530
+
* </pre>
531
+
* <p>
532
+
* For example, using a comment marker {@code '#'} and a comment array {@code comments ["line 1", "line 2"]}:
533
+
* </p>
534
+
* <pre>
535
+
* # line 1
536
+
* # line 2
537
+
* </pre>
525
538
*
539
+
* @return the comment start marker, may be {@code null}
540
+
*/
541
+
542
+
/**
543
+
* Sets the header comments set to the given values. The comments will be printed first, before the headers. This setting is ignored by the parser.
544
+
* <p>
545
+
* Use {@link Builder#setCommentMarker(char)} or {@link Builder#setCommentMarker(Character)} to set the comment marker to be used with each comment.
546
+
* </p>
547
+
* <p>
548
+
* If comment marker is not set (null) then none of header comments will get printed.
549
+
* </p>
550
+
* </p>
551
+
* For an example, if you use comment marker and header comments as below
552
+
* </p>
526
553
* <pre>
527
554
* builder.setHeaderComments("Generated by Apache Commons CSV.", Instant.now());
555
+
* builder.setCommentMarker('#');
556
+
* </pre>
557
+
*<p>
558
+
*you would get header lines printed something similar to below
559
+
*</p>
560
+
* <pre>
561
+
* # Generated by Apache Commons CSV.
562
+
* # 2023-08-25T11:37:51.148073200Z
528
563
* </pre>
529
-
*
530
564
* @param headerComments the headerComments which will be printed by the Printer before the actual CSV data.
531
565
* @return This instance.
532
566
*/
@@ -536,12 +570,27 @@ public Builder setHeaderComments(final Object... headerComments) {
536
570
}
537
571
538
572
/**
539
-
* Sets the header comments set to the given values. The comments will be printed first with the provided comment marker set by {@link Builder#setCommentMarker(char)}, before the headers. This setting is ignored by the parser.
540
-
*
573
+
* Sets the header comments set to the given values. The comments will be printed first, before the headers. This setting is ignored by the parser.
574
+
* <p>
575
+
* Use {@link Builder#setCommentMarker(char)} or {@link Builder#setCommentMarker(Character)} to set the comment marker to be used with each comment.
576
+
* </p>
577
+
* <p>
578
+
* If comment marker is not set (null) then none of header comments will get printed.
579
+
* </p>
580
+
* </p>
581
+
* For an example, if you use comment marker and header comments as below
582
+
* </p>
541
583
* <pre>
542
-
* Builder.setHeaderComments("Generated by Apache Commons CSV.", Instant.now());
584
+
* builder.setHeaderComments("Generated by Apache Commons CSV.", Instant.now());
585
+
* builder.setCommentMarker('#');
586
+
* </pre>
587
+
*<p>
588
+
*you would get header lines printed something similar to below
589
+
*</p>
590
+
* <pre>
591
+
* # Generated by Apache Commons CSV.
592
+
* # 2023-08-25T11:37:51.148073200Z
543
593
* </pre>
544
-
*
545
594
* @param headerComments the headerComments which will be printed by the Printer before the actual CSV data.
0 commit comments