File tree Expand file tree Collapse file tree
main/java/org/apache/commons/csv
test/java/org/apache/commons/csv Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4040 <body >
4141
4242 <release version =" 1.0" date =" TBD" description =" First release" >
43+ <action issue =" CSV-119" type =" add" dev =" ggregory" due-to =" Sergei Lebedev" >CSVFormat is missing a print(...) method</action >
4344 <action issue =" CSV-118" type =" fix" dev =" ggregory" due-to =" Enrique Lara" >CSVRecord.toMap() throws NPE on formats with no
4445 headers.</action >
4546 <action issue =" CSV-113" type =" fix" dev =" sebb" >Check whether ISE/IAE are being used appropriately</action >
Original file line number Diff line number Diff line change @@ -595,6 +595,21 @@ public CSVParser parse(final Reader in) throws IOException {
595595 return new CSVParser (in , this );
596596 }
597597
598+ /**
599+ * Prints to the specified output.
600+ *
601+ * <p>
602+ * See also {@link CSVPrinter}.
603+ * </p>
604+ *
605+ * @param out
606+ * the output
607+ * @return a printer to an output
608+ */
609+ public CSVPrinter print (final Appendable out ) {
610+ return new CSVPrinter (out , this );
611+ }
612+
598613 @ Override
599614 public String toString () {
600615 final StringBuilder sb = new StringBuilder ();
Original file line number Diff line number Diff line change @@ -303,6 +303,15 @@ public void testPrinter7() throws IOException {
303303 printer .close ();
304304 }
305305
306+ @ Test
307+ public void testPrint () throws IOException {
308+ final StringWriter sw = new StringWriter ();
309+ final CSVPrinter printer = CSVFormat .DEFAULT .print (sw );
310+ printer .printRecord ("a" , "b\\ c" );
311+ assertEquals ("a,b\\ c" + recordSeparator , sw .toString ());
312+ printer .close ();
313+ }
314+
306315 @ Test
307316 public void testPrintNullValues () throws IOException {
308317 final StringWriter sw = new StringWriter ();
You can’t perform that action at this time.
0 commit comments