当前位置: 首页>>代码示例>>Java>>正文


Java CsvReader.setRecordDelimiter方法代码示例

本文整理汇总了Java中com.csvreader.CsvReader.setRecordDelimiter方法的典型用法代码示例。如果您正苦于以下问题:Java CsvReader.setRecordDelimiter方法的具体用法?Java CsvReader.setRecordDelimiter怎么用?Java CsvReader.setRecordDelimiter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.csvreader.CsvReader的用法示例。


在下文中一共展示了CsvReader.setRecordDelimiter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test137

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test137() throws Exception {
	CsvReader reader = CsvReader.parse("1;; ;1");
	reader.setRecordDelimiter(';');
	Assert.assertTrue(reader.getSkipEmptyRecords());
	reader.setSkipEmptyRecords(false);
	Assert.assertFalse(reader.getSkipEmptyRecords());
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertEquals("1", reader.get(0));
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertEquals("", reader.get(0));
	Assert.assertEquals(1L, reader.getCurrentRecord());
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertEquals("", reader.get(0));
	Assert.assertEquals(2L, reader.getCurrentRecord());
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertEquals("1", reader.get(0));
	Assert.assertEquals(3L, reader.getCurrentRecord());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:27,代码来源:AllTests.java

示例2: test138

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test138() throws Exception {
	CsvReader reader = CsvReader.parse("1;; ;1");
	reader.setRecordDelimiter(';');
	Assert.assertTrue(reader.getSkipEmptyRecords());
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertEquals("1", reader.get(0));
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertEquals("", reader.get(0));
	Assert.assertEquals(1L, reader.getCurrentRecord());
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertEquals("1", reader.get(0));
	Assert.assertEquals(2L, reader.getCurrentRecord());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:21,代码来源:AllTests.java

示例3: test39

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test39() throws Exception {
	CsvReader reader = CsvReader.parse("user_id,name\r\n1,Bruce");
	Assert.assertTrue(reader.getSafetySwitch());
	reader.setSafetySwitch(false);
	Assert.assertFalse(reader.getSafetySwitch());

	Assert.assertEquals('#', reader.getComment());
	reader.setComment('!');
	Assert.assertEquals('!', reader.getComment());

	Assert.assertEquals(CsvReader.ESCAPE_MODE_DOUBLED, reader
			.getEscapeMode());
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	Assert.assertEquals(CsvReader.ESCAPE_MODE_BACKSLASH, reader
			.getEscapeMode());

	Assert.assertEquals('\0', reader.getRecordDelimiter());
	reader.setRecordDelimiter(';');
	Assert.assertEquals(';', reader.getRecordDelimiter());

	Assert.assertEquals('\"', reader.getTextQualifier());
	reader.setTextQualifier('\'');
	Assert.assertEquals('\'', reader.getTextQualifier());

	Assert.assertTrue(reader.getTrimWhitespace());
	reader.setTrimWhitespace(false);
	Assert.assertFalse(reader.getTrimWhitespace());

	Assert.assertFalse(reader.getUseComments());
	reader.setUseComments(true);
	Assert.assertTrue(reader.getUseComments());

	Assert.assertTrue(reader.getUseTextQualifier());
	reader.setUseTextQualifier(false);
	Assert.assertFalse(reader.getUseTextQualifier());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:39,代码来源:AllTests.java

示例4: test46

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test46() throws Exception {
	String data = "Ch\\icane, Love on the Run, Kn\\ight R\\ider, Th\\is f\\ield conta\\ins an \\i\\, but \\it doesn't matter as \\it \\is escapedi"
			+ "Samuel Barber, Adag\\io for Str\\ings, Class\\ical, Th\\is f\\ield conta\\ins a comma \\, but \\it doesn't matter as \\it \\is escaped";

	CsvReader reader = CsvReader.parse(data);
	reader.setUseTextQualifier(false);
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	reader.setRecordDelimiter('i');
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals("Chicane", reader.get(0));
	Assert.assertEquals("Love on the Run", reader.get(1));
	Assert.assertEquals("Knight Rider", reader.get(2));
	Assert
			.assertEquals(
					"This field contains an i, but it doesn't matter as it is escaped",
					reader.get(3));
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertEquals(4, reader.getColumnCount());
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals("Samuel Barber", reader.get(0));
	Assert.assertEquals("Adagio for Strings", reader.get(1));
	Assert.assertEquals("Classical", reader.get(2));
	Assert
			.assertEquals(
					"This field contains a comma , but it doesn't matter as it is escaped",
					reader.get(3));
	Assert.assertEquals(1L, reader.getCurrentRecord());
	Assert.assertEquals(4, reader.getColumnCount());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:33,代码来源:AllTests.java

示例5: test45

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test45() throws Exception {
	String data = "\"Chicane\", \"Love on the Run\", \"Knight Rider\", \"This field contains a comma, but it doesn't matter as the field is quoted\"i"
			+ "\"Samuel Barber\", \"Adagio for Strings\", \"Classical\", \"This field contains a double quote character, \"\", but it doesn't matter as it is escaped\"";

	CsvReader reader = CsvReader.parse(data);
	Assert.assertTrue(reader.getCaptureRawRecord());
	reader.setCaptureRawRecord(false);
	Assert.assertFalse(reader.getCaptureRawRecord());
	Assert.assertEquals("", reader.getRawRecord());
	reader.setRecordDelimiter('i');
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals("Chicane", reader.get(0));
	Assert.assertEquals("Love on the Run", reader.get(1));
	Assert.assertEquals("Knight Rider", reader.get(2));
	Assert
			.assertEquals(
					"This field contains a comma, but it doesn't matter as the field is quoted",
					reader.get(3));
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertEquals(4, reader.getColumnCount());
	Assert.assertEquals("", reader.getRawRecord());
	Assert.assertFalse(reader.getCaptureRawRecord());
	reader.setCaptureRawRecord(true);
	Assert.assertTrue(reader.getCaptureRawRecord());
	Assert.assertTrue(reader.readRecord());
	Assert
			.assertEquals(
					"\"Samuel Barber\", \"Adagio for Strings\", \"Classical\", \"This field contains a double quote character, \"\", but it doesn't matter as it is escaped\"",
					reader.getRawRecord());
	Assert.assertEquals("Samuel Barber", reader.get(0));
	Assert.assertEquals("Adagio for Strings", reader.get(1));
	Assert.assertEquals("Classical", reader.get(2));
	Assert
			.assertEquals(
					"This field contains a double quote character, \", but it doesn't matter as it is escaped",
					reader.get(3));
	Assert.assertEquals(1L, reader.getCurrentRecord());
	Assert.assertEquals(4, reader.getColumnCount());
	Assert.assertFalse(reader.readRecord());
	Assert.assertTrue(reader.getCaptureRawRecord());
	Assert.assertEquals("", reader.getRawRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:45,代码来源:AllTests.java


注:本文中的com.csvreader.CsvReader.setRecordDelimiter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。