From: <zep...@us...> - 2007-11-03 01:55:34
|
Revision: 365 http://flatpack.svn.sourceforge.net/flatpack/?rev=365&view=rev Author: zepernick Date: 2007-11-02 18:55:33 -0700 (Fri, 02 Nov 2007) Log Message: ----------- Fixed bug 1811210 Modified Paths: -------------- trunk/flatpack/src/main/java/net/sf/flatpack/AbstractDelimiterParser.java trunk/flatpack/src/test/java/net/sf/flatpack/parserutils/ParserUtilsSplitLineTest.java Modified: trunk/flatpack/src/main/java/net/sf/flatpack/AbstractDelimiterParser.java =================================================================== --- trunk/flatpack/src/main/java/net/sf/flatpack/AbstractDelimiterParser.java 2007-10-02 00:51:22 UTC (rev 364) +++ trunk/flatpack/src/main/java/net/sf/flatpack/AbstractDelimiterParser.java 2007-11-03 01:55:33 UTC (rev 365) @@ -215,11 +215,13 @@ protected String fetchNextRecord(final BufferedReader br, final char qual, final char delim) throws IOException { String line = null; final StringBuffer lineData = new StringBuffer(); + final String linebreak = System.getProperty("line.separator"); boolean processingMultiLine = false; while ((line = br.readLine()) != null) { lineCount++; final String trimmed = line.trim(); + final int trimmedLen = trimmed.length(); if (!processingMultiLine && trimmed.length() == 0) { //empty line skip past it, as long as it //is not part of the multiline @@ -240,7 +242,7 @@ // the record final String trimmedLineData = lineData.toString().trim(); - if (processingMultiLine && trimmedLineData.length() > 0) { + if (processingMultiLine && trimmedLineData.length() > 0 && trimmedLen > 0) { // need to do one last check here. it is possible that the " // could be part of the data // excel will escape these with another quote; here is some @@ -250,11 +252,11 @@ // it is safe to assume we have reached the end of the // line break processingMultiLine = false; - lineData.append("\r\n").append(line); + lineData.append(linebreak).append(line); } else { // check to see if this is the last line of the record // looking for a qualifier followed by a delimiter - lineData.append("\r\n").append(line); + lineData.append(linebreak).append(line); boolean qualiFound = false; for (int i = 0; i < chrArry.length; i++) { if (qualiFound) { @@ -296,7 +298,9 @@ } } else { // throw the line into lineData var. - lineData.append(line); + //need to check to see if we need to insert a line break. + //The buffered reader excludes the breaks + lineData.append(trimmedLen == 0 ? linebreak : line); if (processingMultiLine) { continue; // if we are working on a multiline rec, get // the data on the next line Modified: trunk/flatpack/src/test/java/net/sf/flatpack/parserutils/ParserUtilsSplitLineTest.java =================================================================== --- trunk/flatpack/src/test/java/net/sf/flatpack/parserutils/ParserUtilsSplitLineTest.java 2007-10-02 00:51:22 UTC (rev 364) +++ trunk/flatpack/src/test/java/net/sf/flatpack/parserutils/ParserUtilsSplitLineTest.java 2007-11-03 01:55:33 UTC (rev 365) @@ -85,6 +85,12 @@ (String) splitLineResults.get(j)); } } + + ParserUtils.splitLine("26,\"10726/1996\",551,\"Extra\",08/04/2005 00:00:00,0,0,,\"The unanimous judgement of the Team is that:\n" + + "\n" + + "(i) The members have to pay the amount on time. \n" + + "\n" + + "(ii) There would be regular meeting biweekly. \"", ',', '"', 10); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |