Added in API level 3

AutoCloseOutputStream


open class AutoCloseOutputStream : ParcelFileDescriptor.AutoCloseOutputStream

An OutputStream you can create on a ParcelFileDescriptor, which will take care of calling android.os.ParcelFileDescriptor#close for you when the stream is closed.

Summary

Public constructors

Public methods
open Unit
write(buffer: ByteArray!)

open Unit
write(buffer: ByteArray!, offset: Int, count: Int)

open Unit
write(oneByte: Int)

Inherited functions
Unit finalize()

Cleans up the connection to the file, and ensures that the close method of this file output stream is called when there are no more references to this stream.

FileChannel! getChannel()

Returns the unique FileChannel object associated with this file output stream.

The initial position of the returned channel will be equal to the number of bytes written to the file so far unless this stream is in append mode, in which case it will be equal to the size of the file. Writing bytes to this stream will increment the channel's position accordingly. Changing the channel's position, either explicitly or by writing, will change this stream's file position.

FileDescriptor! getFD()

Returns the file descriptor associated with this stream.

Unit write(b: ByteArray!)

Writes b.length bytes from the specified byte array to this file output stream.

Unit write(b: ByteArray!, off: Int, len: Int)

Writes len bytes from the specified byte array starting at offset off to this file output stream.

Unit write(b: Int)

Writes the specified byte to this file output stream. Implements the write method of OutputStream.

Unit flush()

Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

The flush method of OutputStream does nothing.

OutputStream! nullOutputStream()

Returns a new OutputStream which discards all bytes. The returned stream is initially open. The stream is closed by calling the close() method. Subsequent calls to close() have no effect.

While the stream is open, the write(int), write(byte[]), and write(byte[], int, int) methods do nothing. After the stream has been closed, these methods all throw IOException.

The flush() method does nothing.

Public constructors

AutoCloseOutputStream

Added in API level 3
AutoCloseOutputStream(fd: AssetFileDescriptor!)

Public methods

write

Added in API level 3
open fun write(buffer: ByteArray!): Unit
Parameters
b the data.
Exceptions
java.io.IOException if an I/O error occurs.

write

Added in API level 3
open fun write(
    buffer: ByteArray!,
    offset: Int,
    count: Int
): Unit
Parameters
b the data.
off the start offset in the data.
len the number of bytes to write.
Exceptions
java.io.IOException if an I/O error occurs.

write

Added in API level 3
open fun write(oneByte: Int): Unit
Parameters
b the byte to be written.
Exceptions
java.io.IOException if an I/O error occurs.