Class LinesSequence


public class LinesSequence extends ForwardOnlySequence<String>
A sequence that loops over lines from a File, Path, or BufferedReader.
  • Constructor Details

    • LinesSequence

      public LinesSequence(File file)
      Creates a new sequence for the given File.
      Parameters:
      file - the File to loop over
      Throws:
      IllegalArgumentException - if the file is null, does not exist, is a directory, or is not readable.
    • LinesSequence

      public LinesSequence(Path path)
      Creates a new sequence for the given Path.
      Parameters:
      path - the Path to loop over
      Throws:
      IllegalArgumentException - if the path is null, does not exist, is a directory, or is not readable.
    • LinesSequence

      public LinesSequence(BufferedReader reader)
      Creates a new sequence for the given BufferedReader.
      Parameters:
      reader - the BufferedReader to loop over
  • Method Details

    • loop

      public <R> R loop(BiConsumer<Integer,String> consumer)
      Description copied from class: ForwardOnlySequence
      Executes the given consumer for each element in the loop.

      If the array provided to the constructor was null, this method will do nothing.

      Specified by:
      loop in class ForwardOnlySequence<String>
      Type Parameters:
      R - the type of the return value
      Parameters:
      consumer - the consumer to execute for each element
      Returns:
      the value passed to Loop._break_(Object...), or null if the loop completes without a _break_