Find and return the first non-blank line (without trailing newline) in the source.
Find and return the first non-blank line (without trailing newline)
in the source. Uses Source.getLines()
, which may or may not start
at the beginning of the source, depending on the source's state.
None
if there is no nonblank line, Some(line)
if there is.
Find the lines between two marker lines in the source.
Find the lines between two marker lines in the source. For instance, to get all lines between the next occurrence of "
" (on a line by
itself and "
" (or end of file), use:
import grizzled.io.Implicits._ import scala.io.Source import java.io.File val path = "/path/to/some/file" val lines = Source.fromFile(new File(path)).linesBetween("{{{", "
") }}}
This method uses Source.getLines()
, which may or may not start
at the beginning of the source, depending on the source's state.
val lines = Source.fromFile(new File(path)).linesBetween("{{{", " }}} }}}
This method uses Source.getLines()
, which may or may not start
at the beginning of the source, depending on the source's state.
itself and " }}}
import grizzled.io.Implicits._ import scala.io.Source import java.io.File val path = "/path/to/some/file" val lines = Source.fromFile(new File(path)).linesBetween("{{{", "
") }}}
This method uses Source.getLines()
, which may or may not start
at the beginning of the source, depending on the source's state.
val lines = Source.fromFile(new File(path)).linesBetween("{{{", " }}} }}}
This method uses Source.getLines()
, which may or may not start
at the beginning of the source, depending on the source's state.
the starting line marker
the ending line marker
a iterator of lines, or an empty iterator if none found
A wrapper for
scala.io.Source
that provides additional methods. By importing the implicit conversion functions, you can use the methods in this class transparently from ajava.io.File
object.