Add a CloseAction that will be executed each time the resource is closed.
Add a CloseAction that will be executed each time the resource is closed.
the action to add
a new resource instance with the close action added
Read the input as blocks of bytes.
Read the input as blocks of bytes. This method should be avoided unless the maximum performance is absolutely required because bytes provides very good performance and is a better API for most applications.
However since it better reflects how data is read with most input sources (like InputStreams and ReadableByteChannels); blocks is slightly more performance than bytes and therefore can be used when performance is the most important consideration.
block size can optionally be specified but the default is normally acceptable.
Obtains a Traversable for conveniently processing the resource as bytes.
Obtains a Traversable for conveniently processing the resource as bytes.
an non-strict traversable over all the bytes
The characters in the object.
The characters in the object.
If the codec is not the same as the source codec (the codec of the underlying data) then the characters will converted to the desired codec.
The codec representing the desired encoding of the characters
an traversable of all the characters
Get the Resource context that configures how the underlying resource is accessed
Get the Resource context that configures how the underlying resource is accessed
the associated ResourceContext
Obtain the scalax.io.managed.InputStreamResource(typically) version of this object.
Obtain the scalax.io.managed.InputStreamResource(typically) version of this object.
the scalax.io.managed.InputStreamResource(typically) version of this object.
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
normally the error handler registered with the associated ResourceContext will handle any errors opening the resource, but when calling this method the caller must handle any possible errors that are raised.
Obtain the scalax.io.managed.ReadableByteChannelResource(typically) version of this object.
Obtain the scalax.io.managed.ReadableByteChannelResource(typically) version of this object.
the scalax.io.managed.ReadableByteChannelResource(typically) version of this object.
Obtain the scalax.io.ReadCharsResource version of this object.
Obtain the scalax.io.ReadCharsResource version of this object.
the codec used to convert from bytes to characters
the scalax.io.ReadCharsResource version of this object.
Safely calculation the size of the resource or return None in case of failure or if it is not possible to determin size of resource before accessing the resource.
Safely calculation the size of the resource or return None in case of failure or if it is not possible to determin size of resource before accessing the resource.
Create a Resource instance that is configured with the new ResourceContext
Create a Resource instance that is configured with the new ResourceContext
A new ResourceContext
a new instance configured with the new context
Open the resource execute the function and either return all errors as a list or the result of the function execution.
Open the resource execute the function and either return all errors as a list or the result of the function execution.
On open and close error handlers in ResourceContext are called. If they then raise errors the errors are captured and returned as a Right[List[Throwable]]
Perhaps the worst method I have ever written :-(
This method aspires to be the fastest way to read a stream of known length into memory.
This method aspires to be the fastest way to read a stream of known length into memory.
Obtains a Traversable for conveniently processing the file as Ints.
Obtains a Traversable for conveniently processing the file as Ints.
an non-strict traversable over all the bytes with the bytes being represented as Ints
Copy all data from this Input object to the Output object as efficiently as possible.
Copy all data from this Input object to the Output object as efficiently as possible.
output sink to copy the data to
Obtain an non-strict traversable for iterating through the lines in the object
Obtain an non-strict traversable for iterating through the lines in the object
If the codec is not the same as the source codec (the codec of the underlying data) then the characters will converted to the desired codec.
The strategy for determining the end of line Default is to auto-detect the EOL
if true then the line will end with the line terminator Default is false
The codec representing the desired encoding of the characters
a non-strict traversable for iterating through all the lines
The number of bytes that can be read from the underlying resource.
The number of bytes that can be read from the underlying resource.
if length == None then it is not possible to determine the number of bytes in advance.
Loads all the characters into memory.
Loads all the characters into memory. There is no protection against loading very large files/amounts of data.
The codec representing the desired encoding of the characters
Update the current ResourceContext and return a new Resource instance with the updated context
Update the current ResourceContext and return a new Resource instance with the updated context
A function for transforming the current context to a new context with new values.
a new instance configured with the new context
An Resource object that is a also an scalax.io.Input. This trait adds methods for converting between common io types such as to a scalax.io.managed.ReaderResource or scalax.io.managed.ReadableByteChannelResource
the type of underlying resource that is created
1.0