• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java DefaultCsvEncoder类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中org.supercsv.encoder.DefaultCsvEncoder的典型用法代码示例。如果您正苦于以下问题:Java DefaultCsvEncoder类的具体用法?Java DefaultCsvEncoder怎么用?Java DefaultCsvEncoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

DefaultCsvEncoder类属于org.supercsv.encoder包,在下文中一共展示了DefaultCsvEncoder类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testCustomPreference

点赞 3

import org.supercsv.encoder.DefaultCsvEncoder; //导入依赖的package包/类
/**
 * 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());
}
 

开发者ID:super-csv,
项目名称:super-csv,
代码行数:20,
代码来源:CsvPreferenceTest.java

示例2: testCustomPreferenceWithDefaults

点赞 2

import org.supercsv.encoder.DefaultCsvEncoder; //导入依赖的package包/类
/**
 * 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());
}
 

开发者ID:super-csv,
项目名称:super-csv,
代码行数:16,
代码来源:CsvPreferenceTest.java

示例3: testCustomPreferenceBasedOnExisting

点赞 2

import org.supercsv.encoder.DefaultCsvEncoder; //导入依赖的package包/类
/**
 * 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());
}
 

开发者ID:super-csv,
项目名称:super-csv,
代码行数:16,
代码来源:CsvPreferenceTest.java

示例4: getCSVBeanWriter

点赞 2

import org.supercsv.encoder.DefaultCsvEncoder; //导入依赖的package包/类
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;
}
 

开发者ID:qcri-social,
项目名称:AIDR,
代码行数:14,
代码来源:ReadWriteCSV.java

示例5: getCSVMapWriter

点赞 2

import org.supercsv.encoder.DefaultCsvEncoder; //导入依赖的package包/类
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;
}
 

开发者ID:qcri-social,
项目名称:AIDR,
代码行数:12,
代码来源:ReadWriteCSV.java

示例6: createFormat

点赞 2

import org.supercsv.encoder.DefaultCsvEncoder; //导入依赖的package包/类
static
private CsvPreference createFormat(char delimiter, char quote){
	CsvPreference.Builder builder = new CsvPreference.Builder(quote, delimiter, "\n");
	builder.useEncoder(new DefaultCsvEncoder());

	return builder.build();
}
 

开发者ID:openscoring,
项目名称:openscoring,
代码行数:8,
代码来源:CsvUtil.java

示例7: setUp

点赞 2

import org.supercsv.encoder.DefaultCsvEncoder; //导入依赖的package包/类
/**
 * Sets up the DefaultCsvEncoder.
 */
@Before
public void setUp() {
	this.csvEncoder = new DefaultCsvEncoder();
}
 

开发者ID:super-csv,
项目名称:super-csv,
代码行数:8,
代码来源:DefaultCsvEncoderTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)