本文整理匯總了Java中com.csvreader.CsvReader.readRecord方法的典型用法代碼示例。如果您正苦於以下問題:Java CsvReader.readRecord方法的具體用法?Java CsvReader.readRecord怎麽用?Java CsvReader.readRecord使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.csvreader.CsvReader
的用法示例。
在下文中一共展示了CsvReader.readRecord方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: test82
import com.csvreader.CsvReader; //導入方法依賴的package包/類
@Test
public void test82() throws Exception {
StringBuilder holder = new StringBuilder(200010);
for (int i = 0; i < 100000; i++) {
holder.append("a,");
}
holder.append("a");
CsvReader reader = CsvReader.parse(holder.toString());
try {
reader.readRecord();
} catch (Exception ex) {
assertException(
new IOException(
"Maximum column count of 100,000 exceeded in record 0. Set the SafetySwitch property to false if you're expecting more than 100,000 columns per record to avoid this error."),
ex);
}
reader.close();
}
示例2: test91
import com.csvreader.CsvReader; //導入方法依賴的package包/類
@Test
public void test91() throws Exception {
byte[] buffer;
String test = "test";
ByteArrayOutputStream stream = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(stream);
writer.println(test);
writer.close();
buffer = stream.toByteArray();
stream.close();
CsvReader reader = new CsvReader(new ByteArrayInputStream(buffer),
Charset.forName("ISO-8859-1"));
reader.readRecord();
Assert.assertEquals(test, reader.get(0));
reader.close();
}
示例3: test92
import com.csvreader.CsvReader; //導入方法依賴的package包/類
@Test
public void test92() throws Exception {
byte[] buffer;
String test = "test";
ByteArrayOutputStream stream = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(stream);
writer.println(test);
writer.close();
buffer = stream.toByteArray();
stream.close();
CsvReader reader = new CsvReader(new ByteArrayInputStream(buffer), ',',
Charset.forName("ISO-8859-1"));
reader.readRecord();
Assert.assertEquals(test, reader.get(0));
reader.close();
}
示例4: 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數據庫中
}
示例5: test79
import com.csvreader.CsvReader; //導入方法依賴的package包/類
@Test
public void test79() {
CsvReader reader;
reader = CsvReader.parse("");
reader.close();
try {
reader.readRecord();
} catch (Exception ex) {
assertException(
new IOException(
"This instance of the CsvReader class has already been closed."),
ex);
}
}
示例6: test81
import com.csvreader.CsvReader; //導入方法依賴的package包/類
@Test
public void test81() throws Exception {
CsvReader reader = CsvReader.parse(generateString('a', 100001));
try {
reader.readRecord();
} catch (Exception ex) {
assertException(
new IOException(
"Maximum column length of 100,000 exceeded in column 0 in record 0. Set the SafetySwitch property to false if you're expecting column lengths greater than 100,000 characters to avoid this error."),
ex);
}
reader.close();
}
示例7: test83
import com.csvreader.CsvReader; //導入方法依賴的package包/類
@Test
public void test83() throws Exception {
CsvReader reader = CsvReader.parse(generateString('a', 100001));
reader.setSafetySwitch(false);
reader.readRecord();
reader.close();
}
示例8: test84
import com.csvreader.CsvReader; //導入方法依賴的package包/類
@Test
public void test84() throws Exception {
StringBuilder holder = new StringBuilder(200010);
for (int i = 0; i < 100000; i++) {
holder.append("a,");
}
holder.append("a");
CsvReader reader = CsvReader.parse(holder.toString());
reader.setSafetySwitch(false);
reader.readRecord();
reader.close();
}
示例9: test86
import com.csvreader.CsvReader; //導入方法依賴的package包/類
@Test
public void test86() throws Exception {
StringBuilder holder = new StringBuilder(200010);
for (int i = 0; i < 99999; i++) {
holder.append("a,");
}
holder.append("a");
CsvReader reader = CsvReader.parse(holder.toString());
reader.readRecord();
reader.close();
}
示例10: test143
import com.csvreader.CsvReader; //導入方法依賴的package包/類
@Test
public void test143() throws Exception {
CsvReader reader = CsvReader.parse("\"" + generateString('a', 100001)
+ "\"");
try
{
reader.readRecord();
}
catch (Exception ex)
{
assertException(new IOException("Maximum column length of 100,000 exceeded in column 0 in record 0. Set the SafetySwitch property to false if you're expecting column lengths greater than 100,000 characters to avoid this error."), ex);
}
reader.close();
}
示例11: parseData
import com.csvreader.CsvReader; //導入方法依賴的package包/類
public static List<RawDataEntry> parseData(String filepath)
throws FileNotFoundException {
List<RawDataEntry> libreEntrys = new ArrayList<>();
// read file
CsvReader creader = new CsvReader(filepath, '\t', Charset.forName("UTF-8"));
// TODO add stuff
// Teststreifen-Blutzucker (mg/dL)
// Keton (mmol/L)
try {
// validate header
// TODO implement a header-erkenner
for (int i = 0; i < 2; i++) {
creader.readHeaders();
//TODO compute meta data
}
//TODO check header data
// if (!CsvValidator.validateCarelinkHeader(creader)) {
// Logger.getLogger(CarelinkCsvImporter.class.getName()).
// log(Level.SEVERE,
// "Stop parser because of unvalid header:\n"
// + Arrays.toString(Constants.CARELINK_CSV_HEADER[0])
// + "\n{0}", creader.getRawRecord());
// return null;
// }
// read entries
while (creader.readRecord()) {
// Todo cathegorize entry
RawDataEntry entry = parseEntry(creader);
if (entry != null) {
libreEntrys.add(entry);
Logger.getLogger(MedtronicCsvImporter.class.getName()).log(
Level.INFO, "Got Entry: {0}", entry.toString());
} else {
// Logger.getLogger(CarelinkCsvImporter.class.getName()).log(
// Level.FINE, "Drop Entry: {0}", creader.getRawRecord());
}
}
} catch (IOException | ParseException ex) {
Logger.getLogger(MedtronicCsvImporter.class.getName()).log(
Level.SEVERE, "Error while parsing Careling CSV", ex);
} finally {
creader.close();
}
return libreEntrys;
}
示例12: test85
import com.csvreader.CsvReader; //導入方法依賴的package包/類
@Test
public void test85() throws Exception {
CsvReader reader = CsvReader.parse(generateString('a', 100000));
reader.readRecord();
reader.close();
}
示例13: processImport
import com.csvreader.CsvReader; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
protected boolean processImport(final InputStream fileInputStream, final String filenameForLogging) {
importedData = new ArrayList<>();
importedRawData = new ArrayList<>();
final int maxProgress = 100;
//This list is used as a placeholder for future extensions
List<String[]> metaEntries = new ArrayList<>();
this.notifyStatus(0, "Reading Header");
try {
CsvReader creader = null;
if (getDelimiter() == 0) { //try to detect the delimiter by trial and error
LOG.log(Level.INFO, "using automatic delimiter detection");
char[] delimiterList = {',', ';', '\t'};
for (char delimiter : delimiterList) {
creader = getValidatedCreader(delimiter, fileInputStream, metaEntries);
if (null != creader) {
setDelimiter(delimiter);
break;
}
}
} else { // use the delimiter that was set
creader = getValidatedCreader(getDelimiter(), fileInputStream, metaEntries);
}
if (creader == null) { //header could not be validated
LOG.log(Level.WARNING, "No valid header found in File:{0}", filenameForLogging);
return false;
}
// read entries
while (creader.readRecord()) {
/*here the method template is used to process all records */
List<VaultEntry> entryList = parseEntry(creader);
boolean entryIsInterpreted = false;
if (entryList != null && !entryList.isEmpty()) {
for (VaultEntry item : entryList) {
item.setRawId(importedRawData.size()); // add array position as raw id
importedData.add(item);
LOG.log(Level.FINE, "Got Entry: {0}", entryList.toString());
}
entryIsInterpreted = true;
}
importedRawData.add(new RawEntry(creader.getRawRecord(), entryIsInterpreted));
LOG.log(Level.FINER, "Put Raw: {0}", creader.getRawRecord());
}
this.notifyStatus(maxProgress, "Done importing all entries");
} catch (Exception ex) {
LOG.log(Level.WARNING, "Error while parsing CSV: "
+ filenameForLogging, ex);
}
return true;
}