类 LineIter
- 所有已实现的接口:
IterableIter<String>,Closeable,Serializable,AutoCloseable,Iterable<String>,Iterator<String>
public class LineIter
extends ComputeIter<String>
implements IterableIter<String>, Closeable, Serializable
将Reader包装为一个按照行读取的Iterator
此对象遍历结束后,应关闭之,推荐使用方式:
此对象遍历结束后,应关闭之,推荐使用方式:
LineIterator it = null;
try {
it = new LineIterator(reader);
while (it.hasNext()) {
String line = it.nextLine();
// do something with line
}
} finally {
it.close();
}
此类来自于Apache Commons io- 从以下版本开始:
- 4.1.1
- 作者:
- looly
- 另请参阅:
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidclose()关闭Readerprotected Stringprotected booleanisValidLine(String line) 重写此方法来判断是否每一行都被返回,默认全部为true从类继承的方法 com.luna.common.math.ComputeIter
finish, hasNext, next从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 java.lang.Iterable
forEach, spliterator从接口继承的方法 com.luna.common.utils.IterableIter
iterator从接口继承的方法 java.util.Iterator
forEachRemaining, hasNext, next, remove
-
构造器详细资料
-
LineIter
构造- 参数:
in-InputStreamcharset- 编码- 抛出:
IllegalArgumentException- reader为null抛出此异常
-
LineIter
构造- 参数:
reader-Reader对象,不能为null- 抛出:
IllegalArgumentException- reader为null抛出此异常
-
-
方法详细资料
-
computeNext
从类复制的说明:ComputeIter- 指定者:
computeNext在类中ComputeIter<String>- 返回:
- 节点值
-
close
public void close()关闭Reader- 指定者:
close在接口中AutoCloseable- 指定者:
close在接口中Closeable
-
isValidLine
重写此方法来判断是否每一行都被返回,默认全部为true- 参数:
line- 需要验证的行- 返回:
- 是否通过验证
-