All Downloads are FREE. Search and download functionalities are using the official Maven repository.

htsjdk.tribble.readers.LineIteratorImpl Maven / Gradle / Ivy

There is a newer version: 4.1.3
Show newest version
package htsjdk.tribble.readers;

import htsjdk.samtools.util.AbstractIterator;
import htsjdk.samtools.util.CloserUtil;
import htsjdk.samtools.util.RuntimeIOException;

import java.io.Closeable;
import java.io.IOException;

/** A simple iterator over the elements in LineReader. */
public class LineIteratorImpl extends AbstractIterator implements LineIterator, Closeable {
    private final LineReader lineReader;

    /**
     * @param lineReader The line reader whose elements are to be iterated over.
     */
    public LineIteratorImpl(final LineReader lineReader) {
        this.lineReader = lineReader;
    }

    @Override
    protected String advance() {
        try {
            return lineReader.readLine();
        } catch (IOException e) {
            throw new RuntimeIOException(e);
        }
    }

    @Override
    public void close() throws IOException {
        CloserUtil.close(lineReader);
    }
    
    @Override
    public String toString() {
        return "LineIteratorImpl(" + this.lineReader+")";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy