Copy data from an input to this output.
Copy data from an input to this output. Input will call this method from copyTo if it does not know how to efficiently copy the data. This method thus will copy as effiently as possible and if all else fails simply write the bytes
the source to read data from
do not forward request to input's copyTo method. Often only one end of the transaction will know how to efficiently transfer data so a common pattern is to check the input and see if the type of the Input object is a known type. If not then the input object will be sent the request. However, to prevent an infinite loop the finalize will be set to true so the request is not then forwarded back to copyFrom
Execute the function 'f' passing an Output instance that performs all operations on a single opened connection to the underlying resource.
Execute the function 'f' passing an Output instance that performs all operations on a single opened connection to the underlying resource. Typically each call to one of the Output's methods results in a new connection. For example if the underlying OutputStream truncates the file each time the connection is made then calling write two times will result in the contents of the second write overwriting the second write.
Even if the underlying resource is an appending, using open will be more efficient since the connection only needs to be made a single time.
the function to execute on the new Output instance (which uses a single connection)
the result of the function
Writes a string.
Writes a string.
the data to write
the codec of the string to be written. The string will
be converted to the encoding of sourceCodec
Default is sourceCodec
Write data to the underlying object.
Write data to the underlying object. Each time write is called the resource is reopened, in the case of a file this means that the file will be opened and truncated. The
In the case of writing ints and bytes it is often recommended to write arrays of data since normally the underlying object can write arrays of bytes or integers most efficiently.
Since Characters require a codec to write to an OutputStream characters cannot be written with this method unless a OutputWriterFunction.CharFunction object is provided as the writer.
The data to write to underlying object. Any data that has a resolvable OutputConverter can be written. See the OutputConverter object for the defined OutputConverter implementations and classes to assist implementing more.
The strategy used to write the data to the underlying object. Many standard data-types are implicitly resolved and do not need to be supplied
#writeChars for more on writing characters
Since the OutputConverter object defined for writing Ints encodes Ints using 4 bytes this method is provided to simply write an array of Ints as if they are Bytes.
Since the OutputConverter object defined for writing Ints encodes Ints using 4 bytes this method is provided to simply write an array of Ints as if they are Bytes. In other words just taking the first byte. This is pretty common in Java.io style IO. IE
outputStream.write(1)
1 is written as a single byte.
Write several strings.
Write several strings.
The data to write
A string to add between each string. It is not added to the before the first string or after the last.
The codec of the strings to be written. The strings will
be converted to the encoding of sourceCodec
A trait for objects that can have data written to them. For example an OutputStream and File can be an Output object (or be converted to one).
Note: Each invocation of a method will typically open a new stream or channel. That behaviour can be overridden by the implementation but it is the default behaviour.
The consequence of a new stream being opened each time a write is performed is different for each implementation. In the case of a Resource.fromFile reach write will write to the beginning of the file rather than appending to the file.
1.0
WriteChars
,Input
,ReadChars