<action issue="CSV-119" type="add" dev="ggregory" due-to="Sergei Lebedev">CSVFormat is missing a print(...) method</action>

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1599285 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2014-06-02 18:04:49 +00:00
parent 2480dffa6d
commit 65f110ec14
3 changed files with 25 additions and 0 deletions

View File

@ -40,6 +40,7 @@
<body> <body>
<release version="1.0" date="TBD" description="First release"> <release version="1.0" date="TBD" description="First release">
<action issue="CSV-119" type="add" dev="ggregory" due-to="Sergei Lebedev">CSVFormat is missing a print(...) method</action>
<action issue="CSV-118" type="fix" dev="ggregory" due-to="Enrique Lara">CSVRecord.toMap() throws NPE on formats with no <action issue="CSV-118" type="fix" dev="ggregory" due-to="Enrique Lara">CSVRecord.toMap() throws NPE on formats with no
headers.</action> headers.</action>
<action issue="CSV-113" type="fix" dev="sebb">Check whether ISE/IAE are being used appropriately</action> <action issue="CSV-113" type="fix" dev="sebb">Check whether ISE/IAE are being used appropriately</action>

View File

@ -595,6 +595,21 @@ public final class CSVFormat implements Serializable {
return new CSVParser(in, this); return new CSVParser(in, this);
} }
/**
* Prints to the specified output.
*
* <p>
* See also {@link CSVPrinter}.
* </p>
*
* @param out
* the output
* @return a printer to an output
*/
public CSVPrinter print(final Appendable out) {
return new CSVPrinter(out, this);
}
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();

View File

@ -303,6 +303,15 @@ public class CSVPrinterTest {
printer.close(); printer.close();
} }
@Test
public void testPrint() throws IOException {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = CSVFormat.DEFAULT.print(sw);
printer.printRecord("a", "b\\c");
assertEquals("a,b\\c" + recordSeparator, sw.toString());
printer.close();
}
@Test @Test
public void testPrintNullValues() throws IOException { public void testPrintNullValues() throws IOException {
final StringWriter sw = new StringWriter(); final StringWriter sw = new StringWriter();