o1.util
Type members
Classlikes
The contained objects extend various standard API classes with nice convenience methods.
The contained objects extend various standard API classes with nice convenience methods.
Types
A structural supertype for everything that has a close method.
This is an alias for java.lang.AutoCloseable.
A structural supertype for everything that has a close method.
This is an alias for java.lang.AutoCloseable.
- See also:
An alias for convenient use of scala.util.Try via import o1.util.*.
An alias for convenient use of scala.util.Try via import o1.util.*.
An alias for convenient use of java.nio.file.Path via import o1.util.*.
An alias for convenient use of java.nio.file.Path via import o1.util.*.
An alias for convenient use of scala.util.Random via import o1.util.*.
An alias for convenient use of scala.util.Random via import o1.util.*.
An alias for convenient use of scala.io.Source via import o1.util.*.
An alias for convenient use of scala.io.Source via import o1.util.*.
An alias for convenient use of scala.util.Try via import o1.util.*.
An alias for convenient use of scala.util.Try via import o1.util.*.
Value members
Concrete methods
Constructs a new Path object from a given string URL.
Constructs a new Path object from a given string URL.
A macro that returns a string describing the structure (abstract syntax tree) of the given Scala expression.
A macro that returns a string describing the structure (abstract syntax tree) of the given Scala expression.
Searches the working directory and, failing that, the classpath for a readable file
or folder with the given relative path. Returns the Path in an Option wrapper.
Searches the working directory and, failing that, the classpath for a readable file
or folder with the given relative path. Returns the Path in an Option wrapper.
Calls getLines on the given Source and performs the specified effect on each of the lines.
Calls close() on the source even if an exception occurs, but doesn’t catch any exceptions.
Calls getLines on the given Source and performs the specified effect on each of the lines.
Calls close() on the source even if an exception occurs, but doesn’t catch any exceptions.
Performs a given computation and checks to see if it crashes with a NotImplementedError.
Returns the result of the computation in an Option; returns None only in the
computation wasn’t implemented. Any other exception is thrown.
Performs a given computation and checks to see if it crashes with a NotImplementedError.
Returns the result of the computation in an Option; returns None only in the
computation wasn’t implemented. Any other exception is thrown.
- Type parameters:
- Result
the type of the given computation
- Value parameters:
- computation
a computation that may or may not be implemented
Performs a given computation and determines whether it crashes with a NotImplementedError.
Returns true if it did and false otherwise.
Performs a given computation and determines whether it crashes with a NotImplementedError.
Returns true if it did and false otherwise.
- Type parameters:
- Result
the type of the given computation
- Value parameters:
- computation
a computation that may or may not be implemented
Searches the classpath for a file with the given relative path and returns the corresponding Path.
The result comes in an Option wrapper in case no such file is accessible.
Searches the classpath for a file with the given relative path and returns the corresponding Path.
The result comes in an Option wrapper in case no such file is accessible.
Searches the classpath for a file with the given relative path and returns a corresponding Source.
The result comes in an Option wrapper in case no such file is accessible. Assumes UTF-8 encoding.
Searches the classpath for a file with the given relative path and returns a corresponding Source.
The result comes in an Option wrapper in case no such file is accessible. Assumes UTF-8 encoding.
Searches the classpath for a file with the given relative path. Delegates the task to the class loader.
Returns the URL of any found file in an Option wrapper.
Searches the classpath for a file with the given relative path. Delegates the task to the class loader.
Returns the URL of any found file in an Option wrapper.
Reads and returns the lines from a classpath-relative text file. The result comes in an
Option wrapper in case no such file is accessible. Calls close() on the file even if
an exception occurs, but doesn’t catch any exceptions. Assumes UTF-8 encoding.
Reads and returns the lines from a classpath-relative text file. The result comes in an
Option wrapper in case no such file is accessible. Calls close() on the file even if
an exception occurs, but doesn’t catch any exceptions. Assumes UTF-8 encoding.
- Value parameters:
- excludeIfEmpty
whether to exclude (possibly trimmed) empty lines from the return value; if unspecified, defaults to
true- relativePath
the path to a resource; relative to a classpath entry
- trimEach
whether to remove whitespace around each of the lines; if unspecified, defaults to
true
Calls getLines on the given Source and returns the lines in a vector.
Calls close() on the source even if an exception occurs, but doesn’t catch any exceptions.
Calls getLines on the given Source and returns the lines in a vector.
Calls close() on the source even if an exception occurs, but doesn’t catch any exceptions.
- Value parameters:
- excludeIfEmpty
whether to exclude (possibly trimmed) empty lines from the return value; if unspecified, defaults to
true- source
the source to read the lines from
- trimEach
whether to remove whitespace around each of the lines; if unspecified, defaults to
true
Returns, as a single String, the entire contents of a classpath-relative text file. The result
comes in an Option wrapper in case no such file is accessible. Calls close() on the file even
if an exception occurs, but doesn’t catch any exceptions. Assumes UTF-8 encoding.
Returns, as a single String, the entire contents of a classpath-relative text file. The result
comes in an Option wrapper in case no such file is accessible. Calls close() on the file even
if an exception occurs, but doesn’t catch any exceptions. Assumes UTF-8 encoding.
- Value parameters:
- relativePath
the path to a resource; relative to a classpath entry
A macro that prints out the given expressions. Literals are printed as they are, other expressions
as "expr=value". Potentially useful for debugging.
A macro that prints out the given expressions. Literals are printed as they are, other expressions
as "expr=value". Potentially useful for debugging.
Takes in a path or a URL as a string and tries to construct a corresponding Source.
Tries to interpret the given string as one of the following, in order:
Takes in a path or a URL as a string and tries to construct a corresponding Source.
Tries to interpret the given string as one of the following, in order:
- A resource relative to the classpath (as per localURL).
- A complete URL string, with protocol and all (e.g., "http://example.com/").
- A URL string with "http://" missing (e.g., "example.com").
- A URL string with "https://" missing.
Calls
scala.io.Source.fromURLon each of those candidates until a source is successfully constructed or all attempts have failed. Assumes UTF-8 encoding.
- Value parameters:
- pathOrURL
the possible path or URL to a resource
- Returns:
the first
Success, or aFailureif none of the candidates can be read as aSource
Takes in a path or a URL as a string and tries to locate the corresponding resource. Tries to interpret the given string as one of the following (in order until a match is found):
Takes in a path or a URL as a string and tries to locate the corresponding resource. Tries to interpret the given string as one of the following (in order until a match is found):
- A resource relative to the classpath (as per localURL).
- A complete URL string, with protocol and all (e.g., "http://example.com/").
- A URL string with "http://" missing (e.g., "example.com").
- Value parameters:
- pathOrURL
the possible path or URL to a resource
- Returns:
the first
Success, or aFailureif the string isn’t even valid for forming a URL
Attempts to apply the given operation to the given resource and returns the result, making
sure to close the resource. Calls close() on the resource even if the attempt fails with an
exception. Doesn’t catch any exceptions. (This in an implementation of the so-called “loan pattern”.)
Since Scala 2.13, the functionality is available in the standard API, and this is now just an alias
for scala.util.Using.resource.)
Attempts to apply the given operation to the given resource and returns the result, making
sure to close the resource. Calls close() on the resource even if the attempt fails with an
exception. Doesn’t catch any exceptions. (This in an implementation of the so-called “loan pattern”.)
Since Scala 2.13, the functionality is available in the standard API, and this is now just an alias
for scala.util.Using.resource.)
- Value parameters:
- operation
an operation that can be applied to
resource- resource
a resource, such as a file, that has a
close()method
An alias for convenient access to java.lang.System.getProperty("user.dir") via import o1.util.*.
An alias for convenient access to java.lang.System.getProperty("user.dir") via import o1.util.*.
Writes the given text in a new text file at the given filePath. Overwrites any existing file
there. Encodes the output as UTF-8. Calls close() on the output stream even if an exception occurs,
but doesn’t catch any exceptions.
Writes the given text in a new text file at the given filePath. Overwrites any existing file
there. Encodes the output as UTF-8. Calls close() on the output stream even if an exception occurs,
but doesn’t catch any exceptions.
- Value parameters:
- filePath
an absolute path to a local file or a path relative to the working directory
Concrete fields
A label that can be used as an empty method body or other “no-op” block.
A label that can be used as an empty method body or other “no-op” block.
An alias for convenient use of scala.math.Ordering.Double.TotalOrdering via import o1.util.*.
An alias for convenient use of scala.math.Ordering.Double.TotalOrdering via import o1.util.*.
An alias for convenient use of scala.util.Try via import o1.util.*.
An alias for convenient use of scala.util.Try via import o1.util.*.
An alias for convenient use of scala.util.Random via import o1.util.*.
An alias for convenient use of scala.util.Random via import o1.util.*.
An alias for convenient use of scala.io.Source via import o1.util.*.
An alias for convenient use of scala.io.Source via import o1.util.*.
