本文整理汇总了Java中com.csvreader.CsvReader.close方法的典型用法代码示例。如果您正苦于以下问题:Java CsvReader.close方法的具体用法?Java CsvReader.close怎么用?Java CsvReader.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.csvreader.CsvReader
的用法示例。
在下文中一共展示了CsvReader.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例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: test4
import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test4() throws Exception {
String data = "1\r2";
CsvReader reader = CsvReader.parse(data);
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("2", reader.get(0));
Assert.assertEquals(1L, reader.getCurrentRecord());
Assert.assertEquals(1, reader.getColumnCount());
Assert.assertEquals("2", reader.getRawRecord());
Assert.assertFalse(reader.readRecord());
Assert.assertEquals("", reader.getRawRecord());
reader.close();
}
示例4: test6
import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test6() throws Exception {
String data = "1\r\n2";
CsvReader reader = CsvReader.parse(data);
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("2", reader.get(0));
Assert.assertEquals(1L, reader.getCurrentRecord());
Assert.assertEquals(1, reader.getColumnCount());
Assert.assertEquals("2", reader.getRawRecord());
Assert.assertFalse(reader.readRecord());
Assert.assertEquals("", reader.getRawRecord());
reader.close();
}
示例5: test70
import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test70() throws Exception {
String data = "\"1\",Bruce\r\n\"2\",Toni\r\n\"3\",Brian\r\n";
CsvReader reader = CsvReader.parse(data);
reader.setHeaders(new String[] { "userid", "name" });
Assert.assertEquals(2, reader.getHeaderCount());
Assert.assertTrue(reader.readRecord());
Assert.assertEquals("1", reader.get("userid"));
Assert.assertEquals("Bruce", reader.get("name"));
Assert.assertEquals(0L, reader.getCurrentRecord());
Assert.assertEquals(2, reader.getColumnCount());
Assert.assertTrue(reader.readRecord());
Assert.assertEquals("2", reader.get("userid"));
Assert.assertEquals("Toni", reader.get("name"));
Assert.assertEquals(1L, reader.getCurrentRecord());
Assert.assertEquals(2, reader.getColumnCount());
Assert.assertTrue(reader.readRecord());
Assert.assertEquals("3", reader.get("userid"));
Assert.assertEquals("Brian", reader.get("name"));
Assert.assertEquals(2L, reader.getCurrentRecord());
Assert.assertEquals(2, reader.getColumnCount());
Assert.assertFalse(reader.readRecord());
reader.close();
}
示例6: 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();
}
示例7: test10
import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test10() throws Exception {
String data = "1\r2\n";
CsvReader reader = CsvReader.parse(data);
reader.setDelimiter('\r');
Assert.assertTrue(reader.readRecord());
Assert.assertEquals("1", reader.get(0));
Assert.assertEquals("2", reader.get(1));
Assert.assertEquals(0L, reader.getCurrentRecord());
Assert.assertEquals(2, reader.getColumnCount());
Assert.assertEquals("1\r2", reader.getRawRecord());
Assert.assertFalse(reader.readRecord());
Assert.assertEquals("", reader.getRawRecord());
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: 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();
}
示例10: init
import com.csvreader.CsvReader; //导入方法依赖的package包/类
/**
* 存储数据进入InfoMap这个HashMap的操作逻辑
*
* @param activity 本参数传入以便获得raw文本数据(可能传入流的引用更符合设计模式
* @throws IOException
*/
public void init(MainActivity activity) throws IOException {
Connector.getDatabase();
InputStream inputStream = activity.getResources().openRawResource(R.raw.foods);
CsvReader csvReader = new CsvReader(new InputStreamReader(inputStream));
ArrayList<String[]> list = new ArrayList<>();
while (csvReader.readRecord()) {//将csv数据读取到列表中
list.add(csvReader.getValues());
}
csvReader.close();
inputStream.close();
addDataAll(list);//把HashMap中的食物属性信息存入LiteSQL数据库中
}
示例11: test136
import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test136() throws Exception {
CsvReader reader = CsvReader.parse("1\n\n1\r\r1\r\n\r\n1\n\r1");
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("1", 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.assertTrue(reader.readRecord());
Assert.assertEquals(1, reader.getColumnCount());
Assert.assertEquals("1", reader.get(0));
Assert.assertEquals(3L, reader.getCurrentRecord());
Assert.assertTrue(reader.readRecord());
Assert.assertEquals(1, reader.getColumnCount());
Assert.assertEquals("1", reader.get(0));
Assert.assertEquals(4L, reader.getCurrentRecord());
Assert.assertFalse(reader.readRecord());
reader.close();
}
示例12: 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();
}
示例13: test26
import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test26() throws Exception {
String data = "\"Mac \"The Knife\" Peter\",\"Boswell, Jr.\"";
CsvReader reader = CsvReader.parse(data);
Assert.assertTrue(reader.readRecord());
Assert.assertEquals("Mac ", reader.get(0));
Assert.assertEquals("Boswell, Jr.", reader.get(1));
Assert.assertEquals(0L, reader.getCurrentRecord());
Assert.assertEquals(2, reader.getColumnCount());
Assert.assertEquals("\"Mac \"The Knife\" Peter\",\"Boswell, Jr.\"",
reader.getRawRecord());
Assert.assertFalse(reader.readRecord());
reader.close();
}
示例14: test8
import com.csvreader.CsvReader; //导入方法依赖的package包/类
@Test
public void test8() throws Exception {
String data = "1\n";
CsvReader reader = CsvReader.parse(data);
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.assertFalse(reader.readRecord());
Assert.assertEquals("", reader.getRawRecord());
reader.close();
}
示例15: 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();
}