當前位置: 首頁>>代碼示例>>Java>>正文


Java CsvReader.close方法代碼示例

本文整理匯總了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();
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:20,代碼來源: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: 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();
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:20,代碼來源:AllTests.java

示例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();
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:20,代碼來源:AllTests.java

示例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();
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:26,代碼來源:AllTests.java

示例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();
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:21,代碼來源:AllTests.java

示例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();
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:17,代碼來源:AllTests.java

示例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();
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:17,代碼來源:AllTests.java

示例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();
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:19,代碼來源:AllTests.java

示例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數據庫中
}
 
開發者ID:GrayXu,項目名稱:HustEating,代碼行數:20,代碼來源:DataManager.java

示例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();
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:28,代碼來源:AllTests.java

示例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();
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:15,代碼來源:AllTests.java

示例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();
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:16,代碼來源:AllTests.java

示例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();
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:15,代碼來源:AllTests.java

示例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();
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:15,代碼來源:AllTests.java


注:本文中的com.csvreader.CsvReader.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。