copy

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.

Return

the number of bytes copied

Parameters

input

the InputStream to read from

output

the OutputStream to write to

open fun copy(input: InputStream, output: OutputStream): Int

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 .

Parameters

input

the InputStream to read from

output

the Writer to write to

open fun copy(input: InputStream, output: Writer)

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 .

Parameters

encoding

the encoding to use, null means platform default

input

the InputStream to read from

output

the Writer to write to

open fun copy(input: InputStream, output: Writer, encoding: String)

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.

Return

the number of characters copied

Parameters

input

the Reader to read from

output

the Writer to write to

open fun copy(input: Reader, output: Writer): Int

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 .

Parameters

input

the Reader to read from

output

the OutputStream to write to

open fun copy(input: Reader, output: OutputStream)

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 .

Parameters

encoding

the encoding to use, null means platform default

input

the Reader to read from

output

the OutputStream to write to

open fun copy(input: Reader, output: OutputStream, encoding: String)