CharSource.java 文件源码

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

项目:googles-monorepo-demo 作者:
/**
 * Returns an iterable 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 Iterable<String> lines() {
  return new Iterable<String>() {
    @Override
    public Iterator<String> iterator() {
      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();
        }
      };
    }
  };
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号