fix isssue csv-259 (#61)
* fix isssue csv-259 * add testcase for CSV259 * exclude csv259 test file * organize the imports
This commit is contained in:
parent
e503c568a1
commit
953a6de722
2
pom.xml
2
pom.xml
|
@ -256,6 +256,7 @@
|
|||
<exclude>src/test/resources/ferc.gov/contract.txt</exclude>
|
||||
<exclude>src/test/resources/ferc.gov/transaction.txt</exclude>
|
||||
<exclude>src/test/resources/**/*.bin</exclude>
|
||||
<exclude>src/test/resources/CSV-259/sample.txt</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -373,6 +374,7 @@
|
|||
<exclude>src/test/resources/ferc.gov/contract.txt</exclude>
|
||||
<exclude>src/test/resources/ferc.gov/transaction.txt</exclude>
|
||||
<exclude>src/test/resources/**/*.bin</exclude>
|
||||
<exclude>src/test/resources/CSV-259/sample.txt</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
|
|
@ -1408,6 +1408,7 @@ public final class CSVFormat implements Serializable {
|
|||
if (pos > start) {
|
||||
out.append(builder.substring(start, pos));
|
||||
builder.setLength(0);
|
||||
pos = -1;
|
||||
}
|
||||
if (c == LF) {
|
||||
c = 'n';
|
||||
|
|
|
@ -34,6 +34,8 @@ import java.io.PrintStream;
|
|||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.io.Reader;
|
||||
import java.io.FileReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.BatchUpdateException;
|
||||
|
@ -310,6 +312,16 @@ public class CSVPrinterTest {
|
|||
tryFormat(list, '"', '"', "\"\"\"\"\"\",\\\\,\"\\\"\"\\\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCSV259() throws IOException {
|
||||
final StringWriter sw = new StringWriter();
|
||||
final Reader reader = new FileReader("src/test/resources/CSV-259/sample.txt");
|
||||
try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withEscape('!').withQuote(null))) {
|
||||
printer.print(reader);
|
||||
assertEquals("x!,y!,z", sw.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelimeterQuoted() throws IOException {
|
||||
final StringWriter sw = new StringWriter();
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
x,y,z
|
Loading…
Reference in New Issue