Sdílet prostřednictvím


InputStream.TransferTo(Stream) Method

Definition

Reads all bytes from this input stream and writes the bytes to the given output stream in the order that they are read.

[Android.Runtime.Register("transferTo", "(Ljava/io/OutputStream;)J", "GetTransferTo_Ljava_io_OutputStream_Handler", ApiSince=33)]
public virtual long TransferTo (System.IO.Stream? out);
[<Android.Runtime.Register("transferTo", "(Ljava/io/OutputStream;)J", "GetTransferTo_Ljava_io_OutputStream_Handler", ApiSince=33)>]
abstract member TransferTo : System.IO.Stream -> int64
override this.TransferTo : System.IO.Stream -> int64

Parameters

out
Stream

the output stream, non-null

Returns

the number of bytes transferred

Attributes

Remarks

Reads all bytes from this input stream and writes the bytes to the given output stream in the order that they are read. On return, this input stream will be at end of stream. This method does not close either stream.

This method may block indefinitely reading from the input stream, or writing to the output stream. The behavior for the case where the input and/or output stream is asynchronously closed, or the thread interrupted during the transfer, is highly input and output stream specific, and therefore not specified.

If an I/O error occurs reading from the input stream or writing to the output stream, then it may do so after some bytes have been read or written. Consequently the input stream may not be at end of stream and one, or both, streams may be in an inconsistent state. It is strongly recommended that both streams be promptly closed if an I/O error occurs.

Added in 9.

Java documentation for java.io.InputStream.transferTo(java.io.OutputStream).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to