本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}