本文整理汇总了Java中com.csvreader.CsvWriter.setRecordDelimiter方法的典型用法代码示例。如果您正苦于以下问题:Java CsvWriter.setRecordDelimiter方法的具体用法?Java CsvWriter.setRecordDelimiter怎么用?Java CsvWriter.setRecordDelimiter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.csvreader.CsvWriter
的用法示例。
在下文中一共展示了CsvWriter.setRecordDelimiter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test72
import com.csvreader.CsvWriter; //导入方法依赖的package包/类
@Test
public void test72() throws Exception {
byte[] buffer;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
CsvWriter writer = new CsvWriter(stream, ',', Charset
.forName("ISO-8859-1"));
Assert.assertEquals('\0', writer.getRecordDelimiter());
writer.setRecordDelimiter(';');
Assert.assertEquals(';', writer.getRecordDelimiter());
writer.write("a;b");
writer.endRecord();
writer.close();
buffer = stream.toByteArray();
stream.close();
String data = Charset.forName("ISO-8859-1").decode(
ByteBuffer.wrap(buffer)).toString();
Assert.assertEquals("\"a;b\";", data);
}
示例2: test124
import com.csvreader.CsvWriter; //导入方法依赖的package包/类
@Test
public void test124() throws Exception {
byte[] buffer;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
CsvWriter writer = new CsvWriter(stream, ',', Charset
.forName("ISO-8859-1"));
writer.setRecordDelimiter(';');
writer.setUseTextQualifier(false);
writer.setEscapeMode(CsvWriter.ESCAPE_MODE_BACKSLASH);
writer.write("1;2");
writer.endRecord();
writer.close();
buffer = stream.toByteArray();
stream.close();
String data = Charset.forName("ISO-8859-1").decode(
ByteBuffer.wrap(buffer)).toString();
Assert.assertEquals("1\\;2;", data);
}
示例3: test117
import com.csvreader.CsvWriter; //导入方法依赖的package包/类
@Test
public void test117() throws Exception {
byte[] buffer;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
CsvWriter writer = new CsvWriter(stream, ',', Charset
.forName("ISO-8859-1"));
Assert.assertEquals('#', writer.getComment());
writer.setComment('~');
Assert.assertEquals('~', writer.getComment());
writer.setRecordDelimiter(';');
writer.write("1");
writer.endRecord();
writer.writeComment("blah");
writer.close();
buffer = stream.toByteArray();
stream.close();
String data = Charset.forName("ISO-8859-1").decode(
ByteBuffer.wrap(buffer)).toString();
Assert.assertEquals("1;~blah;", data);
}
示例4: test131
import com.csvreader.CsvWriter; //导入方法依赖的package包/类
@Test
public void test131() throws Exception {
byte[] buffer;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
CsvWriter writer = new CsvWriter(stream, ',', Charset
.forName("ISO-8859-1"));
writer.setUseTextQualifier(false);
writer.setEscapeMode(CsvWriter.ESCAPE_MODE_BACKSLASH);
writer.write("1,\\\r\n2");
writer.endRecord();
writer.setRecordDelimiter(';');
writer.write("1,\\;2");
writer.endRecord();
writer.close();
buffer = stream.toByteArray();
stream.close();
String data = Charset.forName("ISO-8859-1").decode(
ByteBuffer.wrap(buffer)).toString();
Assert.assertEquals("1\\,\\\\\\\r\\\n2\r\n1\\,\\\\\\;2;", data);
}