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

org.unix4j.io.AbstractInput Maven / Gradle / Ivy

There is a newer version: 0.6
Show newest version
package org.unix4j.io;

import java.util.Iterator;
import java.util.NoSuchElementException;

import org.unix4j.line.Line;

/**
 * Base implementation for {@link Input} providing the 
 * {@link #iterator() iterator()} method.
 */
abstract public class AbstractInput implements Input {

	@Override
	public Iterator iterator() {
		return new Iterator() {
			@Override
			public boolean hasNext() {
				return hasMoreLines();
			}

			@Override
			public Line next() {
				final Line line = readLine();
				if (line != null) {
					return line;
				}
				throw new NoSuchElementException();
			}

			@Override
			public void remove() {
				throw new UnsupportedOperationException("remove is not supported");
			}
		};
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy