本文整理汇总了Java中org.supercsv.io.ICsvListReader.getHeader方法的典型用法代码示例。如果您正苦于以下问题:Java ICsvListReader.getHeader方法的具体用法?Java ICsvListReader.getHeader怎么用?Java ICsvListReader.getHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.supercsv.io.ICsvListReader
的用法示例。
在下文中一共展示了ICsvListReader.getHeader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readTable
import org.supercsv.io.ICsvListReader; //导入方法依赖的package包/类
/**
* Выполняет формирование таблицы из файла
*
* @param tableName название таблицы
* @param reader сервис чтения файла
*/
protected void readTable(String tableName, ICsvListReader reader) throws DataSetException, IOException {
String[] headers = reader.getHeader(true);
if (headers == null) {
throw new DataSetException(String.format("Table '%s' must contains headers", tableName));
}
Column[] columns = new Column[headers.length];
for (int i = 0; i < headers.length; i++) {
columns[i] = new Column(headers[i], DataType.UNKNOWN);
}
consumer.startTable(new DefaultTableMetaData(tableName, columns));
List<String> row;
while ((row = reader.read()) != null) {
consumer.row(row.toArray());
}
consumer.endTable();
}
示例2: read
import org.supercsv.io.ICsvListReader; //导入方法依赖的package包/类
@Override
public List<Preference> read(InputStream is)
throws Exception {
Map<String, UserPreference> userPreferenceMap = new HashMap<String, UserPreference>();
//List<Preference> elements = new LinkedList<Preference>();
try {
ICsvListReader reader = new CsvListReader(new InputStreamReader(is), /*CsvPreference.STANDARD_PREFERENCE */CsvPreference.EXCEL_NORTH_EUROPE_PREFERENCE);
String[] tokens = reader.getHeader(true);
//elements.add(readPreference(tokens, userPreferenceMap));
int i = 1000;
List<String> element;
while ((element = reader.read()) != null && i-->0) {
tokens = element.toArray(new String[element.size()]);
readPreference(tokens, userPreferenceMap);
//elements.add(readPreference(tokens, userPreferenceMap));
}
} catch (Exception e) {
throw e;
}
return convertUserPreferencesToPreferences(userPreferenceMap);
}
示例3: read
import org.supercsv.io.ICsvListReader; //导入方法依赖的package包/类
@Override
public List<Preference> read(InputStream is)
throws Exception {
List<Preference> elements = new LinkedList<Preference>();
try {
ICsvListReader reader = new CsvListReader(new InputStreamReader(is), CsvPreference.STANDARD_PREFERENCE /*CsvPreference.EXCEL_PREFERENCE*/);
String[] tokens = reader.getHeader(true);
//elements.add(readPreference(tokens));
List<String> element;
while ((element = reader.read()) != null) {
tokens = element.toArray(new String[element.size()]);
elements.add(readPreference(tokens));
}
} catch (Exception e) {
throw e;
}
return elements;
}
示例4: read
import org.supercsv.io.ICsvListReader; //导入方法依赖的package包/类
@Override
public List<IrisPlant> read(InputStream is)
throws Exception {
List<IrisPlant> elements = new LinkedList<IrisPlant>();
try {
ICsvListReader reader = new CsvListReader(new InputStreamReader(is), CsvPreference.STANDARD_PREFERENCE /*CsvPreference.EXCEL_PREFERENCE*/);
String[] tokens = reader.getHeader(true);
elements.add(readIrisPlant(tokens));
List<String> element;
while ((element = reader.read()) != null) {
tokens = element.toArray(new String[element.size()]);
elements.add(readIrisPlant(tokens));
}
} catch (Exception e) {
throw e;
}
return elements;
}