当前位置: 首页>>代码示例>>Java>>正文


Java ICsvBeanReader类代码示例

本文整理汇总了Java中org.supercsv.io.ICsvBeanReader的典型用法代码示例。如果您正苦于以下问题:Java ICsvBeanReader类的具体用法?Java ICsvBeanReader怎么用?Java ICsvBeanReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ICsvBeanReader类属于org.supercsv.io包,在下文中一共展示了ICsvBeanReader类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserialize

import org.supercsv.io.ICsvBeanReader; //导入依赖的package包/类
public List<Airline> deserialize(InputStream in) throws IOException {
    InputStreamReader inputStreamReader = new InputStreamReader(in);
    ICsvBeanReader csvBeanReader = new CsvBeanReader(inputStreamReader, CsvPreference.STANDARD_PREFERENCE);
    final String[] header = {null, "name", "alias", "iataCode", "icaoCode", "callsign", "country", null};
    Airline airline = null;
    List<Airline> airlines = new ArrayList<>();
    try {

        while ((airline = csvBeanReader.read(Airline.class, header, getCellProcessors())) != null) {
            System.out.println("deserialized " + airline);
            airlines.add(airline);
        }
    } finally {
        if (csvBeanReader != null) {
            csvBeanReader.close();
        }
    }
    return airlines;
}
 
开发者ID:Educama,项目名称:Showcase,代码行数:20,代码来源:AirlineCsvDeserializer.java

示例2: deserialize

import org.supercsv.io.ICsvBeanReader; //导入依赖的package包/类
public List<Airport> deserialize(InputStream in) throws IOException {
    InputStreamReader inputStreamReader = new InputStreamReader(in);
    ICsvBeanReader csvBeanReader = new CsvBeanReader(inputStreamReader, CsvPreference.STANDARD_PREFERENCE);
    final String[] header = {null, "name", "city", "country", "iataCode", "icaoCode", "latitude", "longitude", null, null, null, null, null, null};
    Airport airport = null;
    List<Airport> airports = new ArrayList<>();
    try {

        while ((airport = csvBeanReader.read(Airport.class, header, getCellProcessors())) != null) {
            System.out.println("deserialized " + airport);
            airports.add(airport);
        }
    } finally {
        if (csvBeanReader != null) {
            csvBeanReader.close();
        }
    }
    return airports;
}
 
开发者ID:Educama,项目名称:Showcase,代码行数:20,代码来源:AirportCsvDeserializer.java

示例3: deserialize

import org.supercsv.io.ICsvBeanReader; //导入依赖的package包/类
public List<FlightConnection> deserialize(InputStream in) throws IOException {
    InputStreamReader inputStreamReader = new InputStreamReader(in);
    ICsvBeanReader csvBeanReader = new CsvBeanReader(inputStreamReader, CsvPreference.STANDARD_PREFERENCE);
    final String[] header = {"airlineIataCode", null, "sourceAirportIataCode", null, "destinationAirportIataCode", null, "codeshare", "stops", null};
    FlightConnection flightConnection = null;
    List<FlightConnection> flightConnections = new ArrayList<>();
    try {

        while ((flightConnection = csvBeanReader.read(FlightConnection.class, header, getCellProcessors())) != null) {
            System.out.println("deserialized " + flightConnection);
            flightConnections.add(flightConnection);
        }
    } finally {
        if (csvBeanReader != null) {
            csvBeanReader.close();
        }
    }
    return flightConnections;
}
 
开发者ID:Educama,项目名称:Showcase,代码行数:20,代码来源:ConnectionCsvDeserializer.java

示例4: read

import org.supercsv.io.ICsvBeanReader; //导入依赖的package包/类
@Override
public List<T> read(InputStream is)
        throws Exception {

    List<T> elements = new ArrayList<T>();
    try {
        ICsvBeanReader reader = new CsvBeanReader(new InputStreamReader(is), CsvPreference.EXCEL_PREFERENCE);
        String[] headers = mapHeaderNames(reader.getHeader(true));

        T element;
        while ((element = reader.read(type, headers, cellProcessors)) != null) {
            elements.add(element);
        }
    } catch (Exception e) {
        throw e;
    }
    return elements;
}
 
开发者ID:bgokden,项目名称:predictblty,代码行数:19,代码来源:AbstractDataReader.java

示例5: importStream

import org.supercsv.io.ICsvBeanReader; //导入依赖的package包/类
@Override
public void importStream(InputStream inputStream, OnItemHandler handler, String charSetName) throws Exception {

    Reader reader = new InputStreamReader(inputStream, charSetName);

    ICsvBeanReader csvBeanReader = new CsvBeanReader(reader, this.preference);
    Object obj;
    while ((obj = csvBeanReader.<T>read(getDataClass(), this.fieldNames, this.processors)) != null) {
        handler.onItem(obj);
    }

}
 
开发者ID:robeio,项目名称:robe,代码行数:13,代码来源:CSVImporter.java

示例6: read

import org.supercsv.io.ICsvBeanReader; //导入依赖的package包/类
@Override
public List<T> read(InputStream is)
        throws Exception {

    List<T> elements = new ArrayList<>();
    try (ICsvBeanReader reader = new CsvBeanReader(new InputStreamReader(is), CsvPreference.EXCEL_PREFERENCE)) {
        String[] headers = mapHeaderNames(reader.getHeader(true));

        T element;
        while ((element = reader.read(type, headers, cellProcessors)) != null) {
            elements.add(element);
        }
    }
    return elements;
}
 
开发者ID:noctarius,项目名称:hazelcast-mapreduce-presentation,代码行数:16,代码来源:AbstractDataReader.java

示例7: readCpGIsland

import org.supercsv.io.ICsvBeanReader; //导入依赖的package包/类
private List<CpGIsland> readCpGIsland(String fileName) throws IOException {
	List<CpGIsland> cpGIslandList = new ArrayList<>();
	ICsvBeanReader beanReader = new CsvBeanReader(new FileReader(fileName), CsvPreference.TAB_PREFERENCE);
	beanReader.getHeader(true);
	final String[] header = new String[]{"chrom", "chromStart", "chromEnd", "name", null, "cpgNum", null, null, null, null};
	final CellProcessor[] processors = new CellProcessor[]{null, new ParseInt(), new ParseInt(), null, null, new ParseInt(), null, null, null, null};
	CpGIsland cpgIsland;
	while ((cpgIsland = beanReader.read(CpGIsland.class, header, processors)) != null) {
		if (!cpgIsland.getChrom().contains("_") && cpgIsland.getChrom().startsWith("chr")) {
			cpGIslandList.add(cpgIsland);
		}
	}
	return cpGIslandList;
}
 
开发者ID:lancelothk,项目名称:BSPAT,代码行数:15,代码来源:QueryRefGenome.java


注:本文中的org.supercsv.io.ICsvBeanReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。