Skip to content

Commit 6eddaf8

Browse files
committed
Apply configurable row delimiter by Dmitry Drozdov (SANDBOX-329).
git-svn-id: https://svn.apache.org/repos/asf/commons/sandbox/csv/trunk@1003046 13f79535-47bb-0310-9956-ffa450edef68
1 parent 0d63758 commit 6eddaf8

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/java/org/apache/commons/csv/writer/CSVConfig.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public class CSVConfig {
5050
private char fillChar = ' ';
5151
/** The seperator character. Defaults to , */
5252
private char delimiter = ',';
53+
/** The row separator. Defaults to \n */
54+
private String rowDelimiter = "\n";
5355
/** Should we ignore the delimiter. Defaults to false */
5456
private boolean ignoreDelimiter = false;
5557
/** the value delimiter. Defaults to " */
@@ -184,6 +186,21 @@ public void setDelimiter(char delimiter) {
184186
this.delimiter = delimiter;
185187
}
186188

189+
/**
190+
* @return the rowDelimiter used.
191+
*/
192+
public String getRowDelimiter() {
193+
return rowDelimiter;
194+
}
195+
196+
/**
197+
* Set the rowDelimiter to use
198+
* @param rowDelimiter the row delimiter character.
199+
*/
200+
public void setRowDelimiter(String rowDelimiter) {
201+
this.rowDelimiter = rowDelimiter;
202+
}
203+
187204
/**
188205
* @return if the writer should ignore the delimiter character.
189206
*/

src/java/org/apache/commons/csv/writer/CSVWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void writeRecord(Map map) {
7070
}
7171
}
7272
}
73-
sb.append("\n");
73+
sb.append(config.getRowDelimiter());
7474
String line = sb.toString();
7575
writer.write(line);
7676
} catch(Exception e) {

0 commit comments

Comments
 (0)