Add a CloseAction to the end of the CloseAction queue (the last action executed).
Add a CloseAction to the end of the CloseAction queue (the last action executed).
The new action to append
a new instance with the added CloseAction
Creates a new instance of the underlying resource (or opens it).
Creates a new instance of the underlying resource (or opens it). Sometimes the code block used to create the Resource is non-reusable in which case this Resource can only be used once. This is not recommended. When creating a resource it is recommended to pass the code block for creating the resource to the resource so that the resource can be reused. Of course this is not always possible
This method should only be used with care in cases when Automatic
Resource Management cannot be used because the
InputStream
must be closed manually.
This is public only to permit interoperability with certain Java APIs. A better pattern of use should be:
resource.acquireFor { // call java API }
or
val calculatedResult = resource.acquireAndGet { // cal java API that returns a result }
the actual resource that has been opened
Add a CloseAction to the front of the CloseAction queue.
Add a CloseAction to the front of the CloseAction queue.
The new action to prepend
a new instance with the added CloseAction
Creates a CloseAction from the function and passes it to appendCloseAction(CloseAction)
Creates a CloseAction from the function and passes it to appendCloseAction(CloseAction)
The new action to append
a new instance with the added CloseAction
Creates a CloseAction from the function and passes it to prependCloseAction(CloseAction)
Creates a CloseAction from the function and passes it to prependCloseAction(CloseAction)
The new action to prepend
a new instance with the added CloseAction
A Resource that can be used to do IO. Primarily it wraps objects from the java io and makes them more Scala friendly.
A common question about Resource is: "Why no simply expose Input, Output, Seekable, ReadChars, WriteChars? Why do we need a Resource[R] object?"
There are several reasons for this. There are several situations where a developer needs access to the underlying resource.
Perhaps they need to interact with a Java API which does not use the Input, etc... APIs. Another possibility is that the resource may be a specific implementation like PrintStream and they want to use those custom APIs instead of the Scala IO apis. In that case Resource provides them with the ARM functionality that is very useful.
The type of the resource that will be managed by the ManagedResource
1.0