本文整理匯總了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}