CharSource.java 文件源码

java
阅读 35 收藏 0 点赞 0 评论 0

项目:guava-mock 作者:
/**
 * Returns an iterator over the lines in the string. If the string ends in a newline, a final
 * empty string is not included, to match the behavior of BufferedReader/LineReader.readLine().
 */
private Iterator<String> linesIterator() {
  return new AbstractIterator<String>() {
    Iterator<String> lines = LINE_SPLITTER.split(seq).iterator();

    @Override
    protected String computeNext() {
      if (lines.hasNext()) {
        String next = lines.next();
        // skip last line if it's empty
        if (lines.hasNext() || !next.isEmpty()) {
          return next;
        }
      }
      return endOfData();
    }
  };
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号