open static fun copy(input: InputStream!, output: OutputStream!): Int
Copy bytes from an InputStream
to an OutputStream
.
This method buffers the input internally, so there is no need to use a BufferedInputStream
.
Large streams (over 2GB) will return a bytes copied value of -1
after the copy has completed since the correct number of bytes cannot be returned as an int. For large streams use the copyLarge(InputStream, OutputStream)
method.
input
- InputStream!: the InputStream
to read from
output
- OutputStream!: the OutputStream
to write to
NullPointerException
- if the input or output is null
IOException
- if an I/O error occurs
ArithmeticException
- if the byte count is too large
Return
Int: the number of bytes copied
Since
Commons IO 1.1
open static fun copy(input: InputStream!, output: Writer!): Unit
Copy bytes from an InputStream
to chars on a Writer
using the default character encoding of the platform.
This method buffers the input internally, so there is no need to use a BufferedInputStream
.
This method uses InputStreamReader
.
input
- InputStream!: the InputStream
to read from
output
- Writer!: the Writer
to write to
NullPointerException
- if the input or output is null
IOException
- if an I/O error occurs
Since
Commons IO 1.1
open static fun copy(input: InputStream!, output: Writer!, encoding: String!): Unit
Copy bytes from an InputStream
to chars on a Writer
using the specified character encoding.
This method buffers the input internally, so there is no need to use a BufferedInputStream
.
Character encoding names can be found at IANA.
This method uses InputStreamReader
.
input
- InputStream!: the InputStream
to read from
output
- Writer!: the Writer
to write to
encoding
- String!: the encoding to use, null means platform default
NullPointerException
- if the input or output is null
IOException
- if an I/O error occurs
Since
Commons IO 1.1
open static fun copy(input: Reader!, output: Writer!): Int
Copy chars from a Reader
to a Writer
.
This method buffers the input internally, so there is no need to use a BufferedReader
.
Large streams (over 2GB) will return a chars copied value of -1
after the copy has completed since the correct number of chars cannot be returned as an int. For large streams use the copyLarge(Reader, Writer)
method.
input
- Reader!: the Reader
to read from
output
- Writer!: the Writer
to write to
NullPointerException
- if the input or output is null
IOException
- if an I/O error occurs
ArithmeticException
- if the character count is too large
Return
Int: the number of characters copied
Since
Commons IO 1.1
open static fun copy(input: Reader!, output: OutputStream!): Unit
Copy chars from a Reader
to bytes on an OutputStream
using the default character encoding of the platform, and calling flush.
This method buffers the input internally, so there is no need to use a BufferedReader
.
Due to the implementation of OutputStreamWriter, this method performs a flush.
This method uses OutputStreamWriter
.
input
- Reader!: the Reader
to read from
output
- OutputStream!: the OutputStream
to write to
NullPointerException
- if the input or output is null
IOException
- if an I/O error occurs
Since
Commons IO 1.1
open static fun copy(input: Reader!, output: OutputStream!, encoding: String!): Unit
Copy chars from a Reader
to bytes on an OutputStream
using the specified character encoding, and calling flush.
This method buffers the input internally, so there is no need to use a BufferedReader
.
Character encoding names can be found at IANA.
Due to the implementation of OutputStreamWriter, this method performs a flush.
This method uses OutputStreamWriter
.
input
- Reader!: the Reader
to read from
output
- OutputStream!: the OutputStream
to write to
encoding
- String!: the encoding to use, null means platform default
NullPointerException
- if the input or output is null
IOException
- if an I/O error occurs
Since
Commons IO 1.1