public static < T > T splitEachLine ( CharSequence self , Pattern pattern , @ ClosureParams ( value = FromString . class , options = "List<String>" ) Closure < T > closure ) throws IOException { final List < String > list = readLines ( self ) ; T result = null ; for ( String line : list ) { List vals = Arrays . asList ( pattern . split ( line ) ) ; result = closure . call ( vals ) ; } return result ; }
Iterates through the given CharSequence line by line splitting each line using the given separator Pattern . The list of tokens for each line is then passed to the given closure .