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


Java CsvReader.setEscapeMode方法代码示例

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


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

示例1: test28

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test28() throws Exception {
	String data = "\"bob said, \\\"Hey!\\\"\",2, 3 ";

	CsvReader reader = CsvReader.parse(data);
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals("bob said, \"Hey!\"", reader.get(0));
	Assert.assertEquals("2", reader.get(1));
	Assert.assertEquals("3", reader.get(2));
	Assert.assertEquals(',', reader.getDelimiter());
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertEquals(3, reader.getColumnCount());
	Assert.assertEquals("\"bob said, \\\"Hey!\\\"\",2, 3 ", reader
			.getRawRecord());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:19,代码来源:AllTests.java

示例2: test40

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test40() throws Exception {
	String data = "Chicane, Love on the Run, Knight Rider, This field contains a comma\\, but it doesn't matter as the delimiter is escaped";

	CsvReader reader = CsvReader.parse(data);
	reader.setUseTextQualifier(false);
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	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 delimiter is escaped",
					reader.get(3));
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertEquals(4, reader.getColumnCount());
	Assert
			.assertEquals(
					"Chicane, Love on the Run, Knight Rider, This field contains a comma\\, but it doesn't matter as the delimiter is escaped",
					reader.getRawRecord());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:25,代码来源:AllTests.java

示例3: test49

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test49() throws Exception {
	String data = "\"\\n\\r\\t\\b\\f\\e\\v\\a\\z\\d065\\o101\\101\\x41\\u0041\"";

	CsvReader reader = CsvReader.parse(data);
	reader.setUseTextQualifier(true);
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	Assert.assertTrue(reader.readRecord());
	Assert
			.assertEquals("\n\r\t\b\f\u001B\u000B\u0007zAAAAA", reader
					.get(0));
	Assert.assertEquals(
			"\"\\n\\r\\t\\b\\f\\e\\v\\a\\z\\d065\\o101\\101\\x41\\u0041\"",
			reader.getRawRecord());
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:20,代码来源:AllTests.java

示例4: test50

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test50() throws Exception {
	String data = "\\n\\r\\t\\b\\f\\e\\v\\a\\z\\d065\\o101\\101\\x41\\u0041";

	CsvReader reader = CsvReader.parse(data);
	reader.setUseTextQualifier(false);
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	Assert.assertTrue(reader.readRecord());
	Assert
			.assertEquals("\n\r\t\b\f\u001B\u000B\u0007zAAAAA", reader
					.get(0));
	Assert.assertEquals(
			"\\n\\r\\t\\b\\f\\e\\v\\a\\z\\d065\\o101\\101\\x41\\u0041",
			reader.getRawRecord());
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:20,代码来源:AllTests.java

示例5: test51

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test51() throws Exception {
	String data = "\"\\xfa\\u0afa\\xFA\\u0AFA\"";

	CsvReader reader = CsvReader.parse(data);
	reader.setUseTextQualifier(true);
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals("\u00FA\u0AFA\u00FA\u0AFA", reader.get(0));
	Assert.assertEquals("\"\\xfa\\u0afa\\xFA\\u0AFA\"", reader
			.getRawRecord());
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:17,代码来源:AllTests.java

示例6: test147

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test147() throws Exception {
	// testing AppendLetter's buffer
	StringBuilder data = new StringBuilder(20000);
	for (int i = 0; i < 10000; i++) {
		data.append("\\b");
	}

	CsvReader reader = CsvReader.parse(data.toString());
	reader.setUseTextQualifier(false);
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals(generateString('\b', 10000), reader.get(0));
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:17,代码来源:AllTests.java

示例7: test29

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test29() throws Exception {
	String data = "\"double\\\"\\\"double quotes\"";

	CsvReader reader = CsvReader.parse(data);
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals("double\"\"double quotes", reader.get(0));
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertEquals("\"double\\\"\\\"double quotes\"", reader
			.getRawRecord());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:16,代码来源:AllTests.java

示例8: test30

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test30() throws Exception {
	String data = "\"double\\\\\\\\double backslash\"";

	CsvReader reader = CsvReader.parse(data);
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals("double\\\\double backslash", reader.get(0));
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertEquals("\"double\\\\\\\\double backslash\"", reader
			.getRawRecord());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:16,代码来源:AllTests.java

示例9: test36

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test36() throws Exception {
	String data = "\"some \\stuff\"";

	CsvReader reader = CsvReader.parse(data);
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals("some stuff", reader.get(0));
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertEquals("\"some \\stuff\"", reader.getRawRecord());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:15,代码来源:AllTests.java

示例10: 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

示例11: test41

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test41() throws Exception {
	String data = "double\\\\\\\\double backslash";

	CsvReader reader = CsvReader.parse(data);
	reader.setUseTextQualifier(false);
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals("double\\\\double backslash", reader.get(0));
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:15,代码来源:AllTests.java

示例12: test42

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test42() throws Exception {
	String data = "some \\stuff";

	CsvReader reader = CsvReader.parse(data);
	reader.setUseTextQualifier(false);
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals("some stuff", reader.get(0));
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertEquals(1, reader.getColumnCount());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:15,代码来源:AllTests.java

示例13: test43

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test43() throws Exception {
	String data = "\"line 1\\nline 2\",\"line 1\\\nline 2\"";

	CsvReader reader = CsvReader.parse(data);
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals("line 1\nline 2", reader.get(0));
	Assert.assertEquals("line 1\nline 2", reader.get(1));
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertEquals(2, reader.getColumnCount());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:15,代码来源:AllTests.java

示例14: test44

import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test44() throws Exception {
	String data = "line 1\\nline 2,line 1\\\nline 2";

	CsvReader reader = CsvReader.parse(data);
	reader.setUseTextQualifier(false);
	reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
	Assert.assertTrue(reader.readRecord());
	Assert.assertEquals("line 1\nline 2", reader.get(0));
	Assert.assertEquals("line 1\nline 2", reader.get(1));
	Assert.assertEquals(0L, reader.getCurrentRecord());
	Assert.assertEquals(2, reader.getColumnCount());
	Assert.assertFalse(reader.readRecord());
	reader.close();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:16,代码来源:AllTests.java

示例15: 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


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