Skip to content

Commit

Permalink
Fixed problem with blank line in the middle of the output.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gray Watson committed Feb 15, 2019
1 parent 569c9fe commit bd779a5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/j256/simplecsv/processor/CsvProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ private void processQuotedColumn(LineInfo lineInfo, BufferedReader bufferedReade
int sectionEnd = linePos;

StringBuilder sb = null;
while (linePos < line.length()) {
while (true) {

// look for the next quote
sectionEnd = line.indexOf(columnQuote, linePos);
Expand All @@ -1294,7 +1294,7 @@ private void processQuotedColumn(LineInfo lineInfo, BufferedReader bufferedReade
}
// add the end of the line
sb.append(line, sectionStart, line.length());
// is this right if the line termination of the file doesn't match the system?
// add the line-termination in the middle of this column which will _hopefully_ match the file
sb.append(lineTermination);
// restart from the next line read
line = nextLine;
Expand Down
3 changes: 3 additions & 0 deletions src/main/javadoc/doc-files/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.5: 2/15/2019
* Fixed an immediate bug that I found when line-termination character an a blank line are inside a column.

2.4: 2/15/2019
* Added handling of line-termination characters inside of columns if enabled.
* Added a setting to load the fields from any super-classes _before_ the subclasses.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,11 @@ public void testNewlineInColumn() throws Exception {
str = "short\n" + "loooooooooooong\n" + "short";
basic = new Basic(0, str, 0, "foo", false);
testReadWriteBasic(processor, basic);

// blank line in the middle
str = "short\n\n" + "loooooooooooong\n" + "short";
basic = new Basic(0, str, 0, "foo", false);
testReadWriteBasic(processor, basic);
}

@Test(expected = ParseException.class)
Expand Down

0 comments on commit bd779a5

Please sign in to comment.