org.simpleflatmapper.lightningcsv.CloseableCsvReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lightning-csv Show documentation
Show all versions of lightning-csv Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.simpleflatmapper.lightningcsv;
import org.simpleflatmapper.lightningcsv.parser.CellConsumer;
import org.simpleflatmapper.util.CheckedConsumer;
import java.io.Closeable;
import java.io.IOException;
import java.util.Iterator;
//IFJAVA8_START
import java.util.stream.Stream;
//IFJAVA8_END
public class CloseableCsvReader implements Closeable, Iterable {
private final CsvReader delegate;
private final Closeable resource;
public CloseableCsvReader(CsvReader delegate, Closeable resource) {
this.delegate = delegate;
this.resource = resource;
}
public CC parseAll(CC cellConsumer) throws IOException {
return delegate.parseAll(cellConsumer);
}
public boolean parseRow(CellConsumer cellConsumer) throws IOException {
return delegate.parseRow(cellConsumer);
}
public void skipRows(int n) throws IOException {
delegate.skipRows(n);
}
public CC parseRows(CC cellConsumer, int limit) throws IOException {
return delegate.parseRows(cellConsumer, limit);
}
public > RH read(RH handler) throws IOException {
return delegate.read(handler);
}
public > RH read(RH handler, int limit) throws IOException {
return delegate.read(handler, limit);
}
@Override
public Iterator iterator() {
return delegate.iterator();
}
//IFJAVA8_START
public Stream stream() {
return delegate.stream();
}
//IFJAVA8_END
@Override
public void close() throws IOException {
resource.close();
}
}