public class LineIterator extends ComputeIterator<String> implements IterableIterator<String>, Closeable, Serializable
| Constructor and Description |
|---|
LineIterator(InputStream in,
Charset charset)
构造
|
LineIterator(Reader reader)
构造
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
关闭Reader
|
protected String |
computeNext()
计算新的节点,通过实现此方法,当调用
ComputeIterator.hasNext()时将此方法产生的节点缓存,直到调用ComputeIterator.next()取出
当无下一个节点时,须返回null表示遍历结束 |
protected boolean |
isValidLine(String line)
重写此方法来判断是否每一行都被返回,默认全部为true
|
finish, hasNext, nextclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waititeratorforEach, spliteratorforEachRemaining, hasNext, next, removepublic LineIterator(InputStream in, Charset charset) throws IllegalArgumentException
in - InputStreamcharset - 编码IllegalArgumentException - reader为null抛出此异常public LineIterator(Reader reader) throws IllegalArgumentException
reader - Reader对象,不能为nullIllegalArgumentException - reader为null抛出此异常protected String computeNext()
ComputeIteratorComputeIterator.hasNext()时将此方法产生的节点缓存,直到调用ComputeIterator.next()取出
当无下一个节点时,须返回null表示遍历结束computeNext in class ComputeIterator<String>public void close()
close in interface Closeableclose in interface AutoCloseableprotected boolean isValidLine(String line)
line - 需要验证的行Copyright © 2021. All rights reserved.