org.supercsv.encoder.DefaultCsvEncoder Java Examples
The following examples show how to use
org.supercsv.encoder.DefaultCsvEncoder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CsvPreferenceTest.java From super-csv with Apache License 2.0 | 6 votes |
/** * Tests a custom CsvPreference with supplied optional values. */ @Test public void testCustomPreference() { final CsvPreference custom = new CsvPreference.Builder('"', ',', "\n") .surroundingSpacesNeedQuotes(true) .useEncoder(new DefaultCsvEncoder()) .useQuoteMode(new AlwaysQuoteMode()) .setQuoteEscapeChar('\\') .build(); assertEquals('"', custom.getQuoteChar()); assertEquals(',', custom.getDelimiterChar()); assertEquals("\n", custom.getEndOfLineSymbols()); assertTrue(custom.isSurroundingSpacesNeedQuotes()); assertTrue(custom.getEncoder() instanceof DefaultCsvEncoder); assertTrue(custom.getQuoteMode() instanceof AlwaysQuoteMode); assertEquals('\\', custom.getQuoteEscapeChar()); }
Example #2
Source File: CsvPreferenceTest.java From super-csv with Apache License 2.0 | 5 votes |
/** * Tests a custom CsvPreference with default optional values. */ @Test public void testCustomPreferenceWithDefaults() { final CsvPreference custom = new CsvPreference.Builder('"', ',', "\n").build(); assertEquals('"', custom.getQuoteChar()); assertEquals(',', custom.getDelimiterChar()); assertEquals("\n", custom.getEndOfLineSymbols()); assertFalse(custom.isSurroundingSpacesNeedQuotes()); assertNull(custom.getCommentMatcher()); assertTrue(custom.getEncoder() instanceof DefaultCsvEncoder); assertTrue(custom.getQuoteMode() instanceof NormalQuoteMode); assertEquals('"', custom.getQuoteEscapeChar()); }
Example #3
Source File: CsvPreferenceTest.java From super-csv with Apache License 2.0 | 5 votes |
/** * Tests a custom CsvPreference based on an existing constant with supplied optional values. */ @Test public void testCustomPreferenceBasedOnExisting() { final CsvPreference custom = new CsvPreference.Builder(EXCEL_PREFERENCE).surroundingSpacesNeedQuotes(true) .useEncoder(new DefaultCsvEncoder()).useQuoteMode(new AlwaysQuoteMode()).build(); assertEquals(EXCEL_PREFERENCE.getQuoteChar(), custom.getQuoteChar()); assertEquals(EXCEL_PREFERENCE.getDelimiterChar(), custom.getDelimiterChar()); assertEquals(EXCEL_PREFERENCE.getEndOfLineSymbols(), custom.getEndOfLineSymbols()); assertTrue(custom.isSurroundingSpacesNeedQuotes()); assertTrue(custom.getEncoder() instanceof DefaultCsvEncoder); assertTrue(custom.getQuoteMode() instanceof AlwaysQuoteMode); assertEquals(EXCEL_PREFERENCE.getQuoteEscapeChar(), custom.getQuoteEscapeChar()); }
Example #4
Source File: ReadWriteCSV.java From AIDR with GNU Affero General Public License v3.0 | 5 votes |
public ICsvBeanWriter getCSVBeanWriter(String fileToWrite) { try { return new CsvBeanWriter(new FileWriter(fileToWrite, true), new CsvPreference.Builder(CsvPreference.EXCEL_PREFERENCE) .useEncoder(new DefaultCsvEncoder()) .build() ); } catch (IOException e) { // TODO Auto-generated catch block logger.error("Error in creating CSV Bean writer!"); logger.error("Exception",e); } return null; }
Example #5
Source File: ReadWriteCSV.java From AIDR with GNU Affero General Public License v3.0 | 5 votes |
public ICsvMapWriter getCSVMapWriter(String fileToWrite) { try { return new CsvMapWriter(new FileWriterWithEncoding(fileToWrite,"UTF-8", true), new CsvPreference.Builder(CsvPreference.EXCEL_PREFERENCE) .useEncoder(new DefaultCsvEncoder()) .build() ); } catch (IOException e) { logger.error("Error in creating CSV Bean writer!"+e); } return null; }
Example #6
Source File: CsvUtil.java From openscoring with GNU Affero General Public License v3.0 | 5 votes |
static public CsvPreference createFormat(char delimiterChar, char quoteChar){ CsvPreference.Builder builder = new CsvPreference.Builder(quoteChar, delimiterChar, "\n"); builder.useEncoder(new DefaultCsvEncoder()); return builder.build(); }
Example #7
Source File: DefaultCsvEncoderTest.java From super-csv with Apache License 2.0 | 4 votes |
/** * Sets up the DefaultCsvEncoder. */ @Before public void setUp() { this.csvEncoder = new DefaultCsvEncoder(); }