亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? lineiterator.java

?? < JavaME核心技術最佳實踐>>的全部源代碼
?? JAVA
字號:
/*
 * Copyright 2006 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.commons.io;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.util.NoSuchElementException;

/**
 * An Iterator over the lines in a <code>Reader</code>.
 * <p>
 * <code>LineIterator</code> holds a reference to an open <code>Reader</code>.
 * When you have finished with the iterator you should close the reader
 * to free internal resources. This can be done by closing the reader directly,
 * or by calling the {@link #close()} or {@link #closeQuietly(LineIterator)}
 * method on the iterator.
 * <p>
 * The recommended usage pattern is:
 * <pre>
 * LineIterator it = FileUtils.lineIterator(file, "UTF-8");
 * try {
 *   while (it.hasNext()) {
 *     String line = it.nextLine();
 *     /// do something with line
 *   }
 * } finally {
 *   LineIterator.closeQuietly(iterator);
 * }
 * </pre>
 *
 * @author Niall Pemberton
 * @author Stephen Colebourne
 * @author Sandy McArthur
 * @version $Id: LineIterator.java 384037 2006-03-07 22:26:37Z scolebourne $
 * @since Commons IO 1.2
 */
public class LineIterator {

    /** The reader that is being read. */
    private final BufferedReader bufferedReader;
    /** The current line. */
    private String cachedLine;
    /** A flag indicating if the iterator has been fully read. */
    private boolean finished = false;

    /**
     * Constructs an iterator of the lines for a <code>Reader</code>.
     *
     * @param reader the <code>Reader</code> to read from, not null
     * @throws IllegalArgumentException if the reader is null
     */
    public LineIterator(final Reader reader) throws IllegalArgumentException {
        if (reader == null) {
            throw new IllegalArgumentException("Reader must not be null");
        }
        if (reader instanceof BufferedReader) {
            bufferedReader = (BufferedReader) reader;
        } else {
            bufferedReader = new BufferedReader(reader);
        }
    }

    //-----------------------------------------------------------------------
    /**
     * Indicates whether the <code>Reader</code> has more lines.
     * If there is an <code>IOException</code> then {@link #close()} will
     * be called on this instance.
     *
     * @return <code>true</code> if the Reader has more lines
     * @throws IllegalStateException if an IO exception occurs
     */
    public boolean hasNext() {
        if (cachedLine != null) {
            return true;
        } else if (finished) {
            return false;
        } else {
            try {
                while (true) {
                    String line = bufferedReader.readLine();
                    if (line == null) {
                        finished = true;
                        return false;
                    } else if (isValidLine(line)) {
                        cachedLine = line;
                        return true;
                    }
                }
            } catch(IOException ioe) {
                close();
                throw new IllegalStateException(ioe.toString());
            }
        }
    }

    /**
     * Overridable method to validate each line that is returned.
     *
     * @param line  the line that is to be validated
     * @return true if valid, false to remove from the iterator
     */
    protected boolean isValidLine(String line) {
        return true;
    }

    /**
     * Returns the next line in the wrapped <code>Reader</code>.
     *
     * @return the next line from the input
     * @throws NoSuchElementException if there is no line to return
     */
    public Object next() {
        return nextLine();
    }

    /**
     * Returns the next line in the wrapped <code>Reader</code>.
     *
     * @return the next line from the input
     * @throws NoSuchElementException if there is no line to return
     */
    public String nextLine() {
        if (!hasNext()) {
            throw new NoSuchElementException("No more lines");
        }
        String currentLine = cachedLine;
        cachedLine = null;
        return currentLine;        
    }

    /**
     * Closes the underlying <code>Reader</code> quietly.
     * This method is useful if you only want to process the first few
     * lines of a larger file. If you do not close the iterator
     * then the <code>Reader</code> remains open.
     * This method can safely be called multiple times.
     */
    public void close() {
        finished = true;
        IOUtils.closeQuietly(bufferedReader);
        cachedLine = null;
    }

    /**
     * Unsupported.
     *
     * @throws UnsupportedOperationException always
     */
    public void remove() {
        throw new UnsupportedOperationException("Remove unsupported on LineIterator");
    }

    //-----------------------------------------------------------------------
    /**
     * Closes the iterator, handling null and ignoring exceptions.
     *
     * @param iterator  the iterator to close
     */
    public static void closeQuietly(LineIterator iterator) {
        if (iterator != null) {
            iterator.close();
        }
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91美女视频网站| 国产精品视频线看| 日韩精品欧美精品| 欧美一区二区福利视频| 老司机精品视频线观看86| 日韩欧美黄色影院| 大陆成人av片| 亚洲成人资源在线| 欧美sm美女调教| 国产精品亚洲第一区在线暖暖韩国 | 1024成人网| 欧美在线制服丝袜| 蜜桃久久久久久| 久久精品日韩一区二区三区| 色综合久久综合中文综合网| 午夜精品福利一区二区蜜股av | 欧美性大战久久久| 久久精品国产秦先生| 国产精品色在线| 欧美伦理影视网| 国产精品一品二品| 一区二区久久久久久| 日韩三级视频中文字幕| 成人激情综合网站| 五月婷婷综合网| 国产精品无人区| 欧美日韩高清一区二区| 国产91清纯白嫩初高中在线观看| 亚洲精品国产品国语在线app| 日韩一级欧美一级| 99riav久久精品riav| 久久爱另类一区二区小说| 亚洲欧美欧美一区二区三区| 欧美电影免费观看高清完整版在线 | 国产精品乱人伦| 91麻豆精品国产91久久久久| 成人黄色av电影| 日韩精品一二三| 日韩伦理电影网| 日韩一区二区三区四区| 色婷婷综合久久久久中文一区二区 | 日本久久精品电影| 国产伦精品一区二区三区免费迷| 一区二区三区四区蜜桃| 国产免费成人在线视频| 日韩一级高清毛片| 欧美性大战久久久久久久| 成人免费va视频| 国产乱码字幕精品高清av| 日本美女一区二区三区| 亚洲一区二区高清| 国产精品不卡在线| 久久精品人人做| 精品久久久久av影院| 91精品国产免费久久综合| 欧美午夜一区二区三区| 92精品国产成人观看免费| 国产jizzjizz一区二区| 国产一区二区三区免费播放| 蜜桃av一区二区| 日韩电影在线免费看| 亚洲国产sm捆绑调教视频 | 日韩一级片在线观看| 欧美亚洲国产一区二区三区| av一二三不卡影片| 国产不卡在线一区| 丰满岳乱妇一区二区三区| 韩国女主播一区| 国产在线精品免费| 免费在线一区观看| 理论片日本一区| 激情五月婷婷综合| 国产老肥熟一区二区三区| 国内成+人亚洲+欧美+综合在线| 麻豆精品视频在线观看免费| 美腿丝袜在线亚洲一区| 久久精品国产亚洲高清剧情介绍| 日韩成人午夜电影| 久久精品久久99精品久久| 老司机精品视频在线| 韩国v欧美v日本v亚洲v| 国产一区二区成人久久免费影院| 国内不卡的二区三区中文字幕| 精品在线免费观看| 国产91精品在线观看| 99久久伊人精品| 在线这里只有精品| 欧美日韩精品一区二区三区| 欧美精品第1页| 欧美精品一区二区三区高清aⅴ| 欧美不卡在线视频| 国产精品午夜在线| 亚洲永久精品国产| 另类小说色综合网站| 国产成人激情av| 日本电影欧美片| 91精品国产综合久久久久| 精品国产一区二区三区久久久蜜月| 91麻豆精品91久久久久久清纯| 日韩欧美二区三区| 中文字幕乱码久久午夜不卡| 亚洲图片你懂的| 亚洲国产精品尤物yw在线观看| 久久精品国产精品亚洲综合| 丁香激情综合国产| 欧美日韩激情一区| 国产亚洲一区二区三区| 一区二区三区精品在线| 日本91福利区| 99re亚洲国产精品| 91精品国模一区二区三区| 欧美国产精品中文字幕| 亚洲成人第一页| 福利电影一区二区| 欧美久久一二三四区| 国产日产亚洲精品系列| 一区二区三区四区在线播放| 国产一区二区在线看| 色综合一个色综合亚洲| 精品粉嫩aⅴ一区二区三区四区| 亚洲国产精品黑人久久久| 午夜日韩在线电影| 成人黄色片在线观看| 欧美一区二区三区婷婷月色| 最新日韩在线视频| 久久电影国产免费久久电影| 色妞www精品视频| 久久一区二区三区四区| 性做久久久久久| aaa欧美日韩| 久久这里只有精品6| 亚洲18色成人| 91一区二区三区在线观看| 久久这里只有精品首页| 日韩高清在线电影| 色94色欧美sute亚洲线路一久| 久久综合色一综合色88| 日本aⅴ亚洲精品中文乱码| 色94色欧美sute亚洲13| 国产精品国产自产拍高清av王其 | 亚洲私人黄色宅男| 国产精品主播直播| 精品美女在线观看| 日日夜夜精品视频天天综合网| 93久久精品日日躁夜夜躁欧美| 久久夜色精品国产噜噜av| 日韩和欧美一区二区三区| 91麻豆免费视频| 国产精品你懂的在线| 狠狠色丁香婷婷综合| 99久久国产综合精品女不卡| 久久品道一品道久久精品| 性欧美大战久久久久久久久| 在线精品观看国产| 夜夜嗨av一区二区三区网页| 色婷婷综合久久久久中文| 国产精品国产三级国产专播品爱网 | 丁香五精品蜜臀久久久久99网站 | 亚洲午夜久久久| 国产成人综合视频| 日韩精品中文字幕一区| 蜜桃视频第一区免费观看| 911精品国产一区二区在线| 水蜜桃久久夜色精品一区的特点| 欧美在线看片a免费观看| 亚洲免费在线视频一区 二区| 99re热视频精品| 亚洲天堂av老司机| 91在线小视频| 亚洲免费伊人电影| 欧美性色黄大片手机版| 性做久久久久久免费观看| 欧美日韩精品欧美日韩精品一 | 天天操天天色综合| 91精品国产综合久久久蜜臀图片| 丝袜美腿一区二区三区| 日韩欧美高清dvd碟片| 午夜电影一区二区| 欧美大黄免费观看| 国产成人在线观看免费网站| 中文字幕一区在线观看视频| 91麻豆国产精品久久| 亚洲在线成人精品| 欧美精品乱码久久久久久按摩| 欧美aaa在线| 国产午夜精品一区二区三区嫩草 | 欧美一区二区在线免费观看| 六月丁香综合在线视频| 日本一区二区三区在线观看| aaa国产一区| 午夜欧美一区二区三区在线播放 | 国产欧美日韩另类一区| 风间由美中文字幕在线看视频国产欧美| 国产精品你懂的| 欧美影片第一页| 精品无人码麻豆乱码1区2区| 国产精品久久久久aaaa| 欧美人与禽zozo性伦| 国产一区二区成人久久免费影院| 中文字幕日韩一区二区|