From 1746b7475d2400d85f5a7c70e1a4ecf821c683ff Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Wed, 14 Mar 2012 20:12:32 +0000 Subject: [PATCH] Document why we use CRLF rather than local line separator git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1300706 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/java/org/apache/commons/csv/CSVFormat.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/csv/CSVFormat.java b/src/main/java/org/apache/commons/csv/CSVFormat.java index 55c77b8f..23157967 100644 --- a/src/main/java/org/apache/commons/csv/CSVFormat.java +++ b/src/main/java/org/apache/commons/csv/CSVFormat.java @@ -29,6 +29,8 @@ import java.io.StringWriter; */ public class CSVFormat implements Serializable { + /** According to RFC 4180, line breaks are delimited by CRLF */ + private static final String CRLF = "\r\n"; private final char delimiter; private final char encapsulator; private final char commentStart; @@ -49,7 +51,7 @@ public class CSVFormat implements Serializable { static final char DISABLED = '\ufffe'; /** Standard comma separated format as defined by RFC 4180. */ - public static final CSVFormat DEFAULT = new CSVFormat(',', '"', DISABLED, DISABLED, true, true, false, true, "\r\n"); + public static final CSVFormat DEFAULT = new CSVFormat(',', '"', DISABLED, DISABLED, true, true, false, true, CRLF); /** * Excel file format (using a comma as the value delimiter). @@ -62,10 +64,10 @@ public class CSVFormat implements Serializable { * *
CSVFormat fmt = CSVFormat.EXCEL.withDelimiter(';');
*/ - public static final CSVFormat EXCEL = new CSVFormat(',', '"', DISABLED, DISABLED, false, false, false, false, "\r\n"); + public static final CSVFormat EXCEL = new CSVFormat(',', '"', DISABLED, DISABLED, false, false, false, false, CRLF); /** Tab-delimited format, with quote; leading and trailing spaces ignored. */ - public static final CSVFormat TDF = new CSVFormat('\t', '"', DISABLED, DISABLED, true, true, false, true, "\r\n"); + public static final CSVFormat TDF = new CSVFormat('\t', '"', DISABLED, DISABLED, true, true, false, true, CRLF); /** * Default MySQL format used by the SELECT INTO OUTFILE and