本文整理汇总了Java中com.csvreader.CsvReader.setUseTextQualifier方法的典型用法代码示例。如果您正苦于以下问题:Java CsvReader.setUseTextQualifier方法的具体用法?Java CsvReader.setUseTextQualifier怎么用?Java CsvReader.setUseTextQualifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.csvreader.CsvReader
的用法示例。
在下文中一共展示了CsvReader.setUseTextQualifier方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test23
import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test23() throws Exception {
String data = generateString('a', 75) + "," + generateString('b', 75);
CsvReader reader = CsvReader.parse(data);
reader.setUseTextQualifier(false);
Assert.assertTrue(reader.readRecord());
Assert.assertEquals(reader.get(0), generateString('a', 75));
Assert.assertEquals(reader.get(1), generateString('b', 75));
Assert.assertEquals(0L, reader.getCurrentRecord());
Assert.assertEquals(2, reader.getColumnCount());
Assert.assertEquals(generateString('a', 75) + ","
+ generateString('b', 75), reader.getRawRecord());
Assert.assertFalse(reader.readRecord());
reader.close();
}
示例2: test24
import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test24() throws Exception {
String data = "1\r\n\r\n1";
CsvReader reader = CsvReader.parse(data);
reader.setUseTextQualifier(false);
Assert.assertTrue(reader.readRecord());
Assert.assertEquals("1", reader.get(0));
Assert.assertEquals(0L, reader.getCurrentRecord());
Assert.assertEquals(1, reader.getColumnCount());
Assert.assertEquals("1", reader.getRawRecord());
Assert.assertTrue(reader.readRecord());
Assert.assertEquals("1", reader.get(0));
Assert.assertEquals(1L, reader.getCurrentRecord());
Assert.assertEquals(1, reader.getColumnCount());
Assert.assertEquals("1", reader.getRawRecord());
Assert.assertFalse(reader.readRecord());
reader.close();
}
示例3: test25
import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test25() throws Exception {
String data = "1\r\n# bunch of crazy stuff here\r\n1";
CsvReader reader = CsvReader.parse(data);
reader.setUseTextQualifier(false);
reader.setUseComments(true);
Assert.assertTrue(reader.readRecord());
Assert.assertEquals("1", reader.get(0));
Assert.assertEquals(0L, reader.getCurrentRecord());
Assert.assertEquals(1, reader.getColumnCount());
Assert.assertEquals("1", reader.getRawRecord());
Assert.assertTrue(reader.readRecord());
Assert.assertEquals("1", reader.get(0));
Assert.assertEquals(1L, reader.getCurrentRecord());
Assert.assertEquals(1, reader.getColumnCount());
Assert.assertEquals("1", reader.getRawRecord());
Assert.assertFalse(reader.readRecord());
reader.close();
}
示例4: 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();
}
示例5: 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();
}
示例6: 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();
}
示例7: 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();
}
示例8: 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();
}
示例9: test22
import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test22() throws Exception {
String data = "\"data \"\" here\"";
CsvReader reader = CsvReader.parse(data);
reader.setUseTextQualifier(false);
Assert.assertTrue(reader.readRecord());
Assert.assertEquals("\"data \"\" here\"", reader.get(0));
Assert.assertEquals(0L, reader.getCurrentRecord());
Assert.assertEquals(1, reader.getColumnCount());
Assert.assertEquals("\"data \"\" here\"", 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: 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();
}
示例14: 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();
}
示例15: test52
import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test52() throws Exception {
String data = "\\xfa\\u0afa\\xFA\\u0AFA";
CsvReader reader = CsvReader.parse(data);
reader.setUseTextQualifier(false);
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();
}