diff --git a/src/main/java/org/apache/commons/csv/CSVFormat.java b/src/main/java/org/apache/commons/csv/CSVFormat.java index 40b2d007..d7d5ccba 100644 --- a/src/main/java/org/apache/commons/csv/CSVFormat.java +++ b/src/main/java/org/apache/commons/csv/CSVFormat.java @@ -1679,6 +1679,15 @@ public final class CSVFormat implements Serializable { return delimiter.charAt(0); } + /** + * Gets the character delimiting the values (typically ";", "," or "\t"). + * + * @return the delimiter. + */ + char[] getDelimiterCharArray() { + return delimiter.toCharArray(); + } + /** * Gets the character delimiting the values (typically ";", "," or "\t"). * @@ -2126,7 +2135,7 @@ public final class CSVFormat implements Serializable { int start = 0; int pos = 0; final int end = charSeq.length(); - final char[] delim = getDelimiterString().toCharArray(); + final char[] delim = getDelimiterCharArray(); final int delimLength = delim.length; final char escape = getEscapeCharacter().charValue(); while (pos < end) { @@ -2168,7 +2177,7 @@ public final class CSVFormat implements Serializable { int pos = 0; @SuppressWarnings("resource") // Temp reader on input reader. final ExtendedBufferedReader bufferedReader = new ExtendedBufferedReader(reader); - final char[] delim = getDelimiterString().toCharArray(); + final char[] delim = getDelimiterCharArray(); final int delimLength = delim.length; final char escape = getEscapeCharacter().charValue(); final StringBuilder builder = new StringBuilder(IOUtils.DEFAULT_BUFFER_SIZE); @@ -2217,7 +2226,7 @@ public final class CSVFormat implements Serializable { int start = 0; int pos = 0; final int len = charSeq.length(); - final char[] delim = getDelimiterString().toCharArray(); + final char[] delim = getDelimiterCharArray(); final int delimLength = delim.length; final char quoteChar = getQuoteCharacter().charValue(); // If escape char not specified, default to the quote char diff --git a/src/main/java/org/apache/commons/csv/Lexer.java b/src/main/java/org/apache/commons/csv/Lexer.java index eeb39a64..ef379ec3 100644 --- a/src/main/java/org/apache/commons/csv/Lexer.java +++ b/src/main/java/org/apache/commons/csv/Lexer.java @@ -65,7 +65,7 @@ final class Lexer implements Closeable { Lexer(final CSVFormat format, final ExtendedBufferedReader reader) { this.reader = reader; - this.delimiter = format.getDelimiterString().toCharArray(); + this.delimiter = format.getDelimiterCharArray(); this.escape = mapNullToDisabled(format.getEscapeCharacter()); this.quoteChar = mapNullToDisabled(format.getQuoteCharacter()); this.commentStart = mapNullToDisabled(format.getCommentMarker());