tinyscalautils.io

Members list

Type members

Classlikes

Text inputs, suitable to the read and readAll functions.

Text inputs, suitable to the read and readAll functions.

Attributes

Companion
object
Source
Input.scala
Supertypes
class Object
trait Matchable
class Any
object Input

Attributes

Companion
trait
Source
Input.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Input.type

Text outputs, suitable to the write and writeAll functions.

Text outputs, suitable to the write and writeAll functions.

Attributes

Companion
object
Source
Output.scala
Supertypes
class Object
trait Matchable
class Any
object Output

Attributes

Companion
trait
Source
Output.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Output.type

Value members

Concrete methods

def listPaths(dir: Path, silent: Boolean): List[Path]

The list of files and subdirectories in a directory, in no particular order.

The list of files and subdirectories in a directory, in no particular order.

Value parameters

silent

if true, errors are ignored, and an empty list is returned.

Attributes

Throws
IllegalArgumentException

if the path is not a directory.

Since

1.0

Source
files.scala
def read[I](in: I, silent: Boolean)(using evidence$1: Input[I]): String

Reads a text file as a single string. Encoding is UTF8.

Reads a text file as a single string. Encoding is UTF8.

Value parameters

in

the source to read.

silent

if true, errors are ignored, and an empty string is returned.

Attributes

Since

1.3

Note

If the input is closable, this function closes it.

Source
Input.scala
def readAll[A, C[_], I](factory: IterableFactory[C])(in: I, parser: String => IterableOnce[A], silent: Boolean)(using evidence$1: Input[I]): C[A]

Parses a text source (sequence of lines) using a given parser to split each line. Lines that parse to an empty sequence (such as None) are ignored. Encoding is UTF8.

Parses a text source (sequence of lines) using a given parser to split each line. Lines that parse to an empty sequence (such as None) are ignored. Encoding is UTF8.

Value parameters

factory

a factory for the desired collection type.

in

the source to parse.

parser

the parser to use; if omitted, each line is taken as a whole except blank lines, which are ignored.

silent

if true, errors are ignored, and an empty collection is returned.

Attributes

Returns

a factory-based collection of all the parts of all the lines.

Since

1.3

Note

If the input is closable, this function closes it.

Source
Input.scala
def readAll[A, I](in: I, parser: String => IterableOnce[A], silent: Boolean)(using evidence$1: Input[I]): List[A]

Simplified form of readAll that uses List as the factory.

Simplified form of readAll that uses List as the factory.

Attributes

Since

1.3

Source
Input.scala
def readAll[A, I](in: I, parser: String => IterableOnce[A])(using evidence$1: Input[I]): List[A]

Simplified form of readAll that uses List as the factory and false for the silent argument.

Simplified form of readAll that uses List as the factory and false for the silent argument.

Attributes

Since

1.3

Source
Input.scala
def readAll[I](in: I, silent: Boolean)(using evidence$1: Input[I]): List[String]

Simplified form of readAll that does not parse (blank lines are ignored) and uses List as the factory.

Simplified form of readAll that does not parse (blank lines are ignored) and uses List as the factory.

Attributes

Since

1.3

Source
Input.scala
def readAll[I](in: I)(using evidence$1: Input[I]): List[String]

Simplified form of readAll that does not parse (blank lines are ignored), uses List as the factory, and uses false for the silent argument.

Simplified form of readAll that does not parse (blank lines are ignored), uses List as the factory, and uses false for the silent argument.

Attributes

Since

1.3

Source
Input.scala
def readPaths[C[_]](factory: IterableFactory[C])(dir: Path, silent: Boolean): C[Path]

The collection of files and subdirectories in a directory, in no particular order.

The collection of files and subdirectories in a directory, in no particular order.

Value parameters

factory

a factory for the desired collection type.

silent

if true, errors are ignored, and an empty collection is returned.

Attributes

Throws
IllegalArgumentException

if the path is not a directory.

Since

1.0

Source
files.scala
def readingAll[A, I](in: I, parser: String => IterableOnce[A])(using evidence$1: Input[I]): Iterator[A] & Closeable

Parses a text source (sequence of lines) using a given parser to split each line. Lines that parse to an empty sequence (such as None) are ignored. Encoding is UTF8.

Parses a text source (sequence of lines) using a given parser to split each line. Lines that parse to an empty sequence (such as None) are ignored. Encoding is UTF8.

Value parameters

in

the source to parse.

parser

the parser to use; if omitted, each line is taken as a whole except blank lines, which are ignored.

Attributes

Returns

an iterator of all the parts of all the lines; closing this iterator closes the underlying source.

Since

1.3

Source
Input.scala
def write[O](out: O, newline: Boolean)(str: CharSequence)(using evidence$1: Output[O]): Unit

Writes the string into a destination. Nothing is added, unless when newLine = true, which adds a final newline. Encoding is UTF8.

Writes the string into a destination. Nothing is added, unless when newLine = true, which adds a final newline. Encoding is UTF8.

Value parameters

newline

when true, adds a final newline to the output.

out

the destination to write to.

Attributes

Note

Uses CharSequence instead of Any to avoid accidental calls to write that were intended to be writeAll.

If the destination is closable, this function closes it.

Source
Output.scala
def writeAll[A, O](pre: String, sep: String, post: String)(out: O)(values: IterableOnce[A])(using evidence$1: Output[O]): Unit

Writes the string representations of a collection of values into a destination. The three arguments pre, sep, and post are as in mkString. Encoding is UTF8.

Writes the string representations of a collection of values into a destination. The three arguments pre, sep, and post are as in mkString. Encoding is UTF8.

Value parameters

out

the destination to write to.

Attributes

Note

If the destination is closable, this function closes it.

Source
Output.scala
def writeAll[A, O](out: O)(values: IterableOnce[A])(using evidence$1: Output[O]): Unit

Writes the string representations of a collection of values into a destination. Each value is followed by a newline, including the last.

Writes the string representations of a collection of values into a destination. Each value is followed by a newline, including the last.

Value parameters

out

the destination to write to.

Attributes

Note

If the destination is closable, this function closes it.

Source
Output.scala

Deprecated methods

def listLines(file: Path, silent: Boolean): List[String]

Attributes

Deprecated
[Since version 1.3]
Source
files.scala
def parseURL[A, C[_]](url: URL, parser: String => IterableOnce[A], factory: IterableFactory[C]): C[A]

Attributes

Deprecated
[Since version 1.3]
Source
resources.scala
def readLines[C[_]](factory: IterableFactory[C])(file: Path, silent: Boolean): C[String]

Attributes

Deprecated
[Since version 1.3]
Source
files.scala

Concrete fields

Identity parsing. By using it as a parser argument of readAll, lines are returned unchanged.

Identity parsing. By using it as a parser argument of readAll, lines are returned unchanged.

Attributes

Source
Input.scala

Givens

Givens

Attributes

Source
Input.scala

Attributes

Source
Output.scala

Attributes

Source
Input.scala

Attributes

Source
Output.scala

Attributes

Source
Input.scala

Attributes

Source
Input.scala

Attributes

Source
Output.scala

Attributes

Source
Input.scala
given URIIsInput: Input[URI]

Attributes

Source
Input.scala
given URLIsInput: Input[URL]

Attributes

Source
Input.scala

Attributes

Source
Input.scala

Extensions

Extensions

extension [I](in: I)(using evidence$1: Input[I])
def source: Source

Opens the input as a source.

Opens the input as a source.

Attributes

Source
Input.scala
extension (obj: AnyRef)
def findResource(name: String): URL

Finds the given resource as a URL. This is simply a call to getClass.getResource that throws MissingResourceException instead of returning null.

Finds the given resource as a URL. This is simply a call to getClass.getResource that throws MissingResourceException instead of returning null.

Like getResource, paths that start with a slash are absolute, and relative paths are relative to the full package name.

Attributes

See also
Since

1.0

Source
resources.scala
def findResource(fallback: URI)(name: String): URL

Finds the given resource as a URL. This is simply a call to getClass.getResource that falls back to a default location instead of returning null. Note that this findResource variant does not throw MissingResourceException.

Finds the given resource as a URL. This is simply a call to getClass.getResource that falls back to a default location instead of returning null. Note that this findResource variant does not throw MissingResourceException.

Like getResource, paths that start with a slash are absolute, and relative paths are relative to the full package name. Paths are always treated as relative to the URI when the fallback is used.

Value parameters

fallback

a fallback URI, which must be absolute.

Attributes

See also
Since

1.3

Source
resources.scala

Finds the given resource as a stream. If the resource is not found, then name.gz is tried instead and, if found, opened as GZIP compressed data. (If name already ends with .gz, no attempt is made with a .gz.gz name.)

Finds the given resource as a stream. If the resource is not found, then name.gz is tried instead and, if found, opened as GZIP compressed data. (If name already ends with .gz, no attempt is made with a .gz.gz name.)

Like getResource, paths that start with a slash are absolute, and relative paths are relative to the full package name.

Attributes

See also
Since

1.3

Source
resources.scala
def findResourceAsStream(fallback: URI)(name: String): InputStream

Finds the given resource as a stream. If the resource is not found, then name.gz is tried instead. If neither is found locally, the fallback location is used to search for name.gz first and, if unsuccessful, for name. When a .gz file is found, either locally or remotely, it is opened as GZIP compressed data. If name already ends with .gz, no attempt is made with a .gz.gz name.

Finds the given resource as a stream. If the resource is not found, then name.gz is tried instead. If neither is found locally, the fallback location is used to search for name.gz first and, if unsuccessful, for name. When a .gz file is found, either locally or remotely, it is opened as GZIP compressed data. If name already ends with .gz, no attempt is made with a .gz.gz name.

Like getClass.getResource, paths that start with a slash are absolute, and relative paths are relative to the full package name.

Attributes

See also
Since

1.3

Source
resources.scala
extension [O](out: O)(using evidence$1: Output[O])

Opens the output as a stream.

Opens the output as a stream.

Attributes

Source
Output.scala