OutputStream class methods in Java

java.io.OutputStream

This abstract class is the superclass of all classes representing an output stream of bytes. An output stream accepts output bytes and sends them to some sink.

Applications that need to define a subclass of OutputStream must always provide at least a method that writes one byte of output.

The OutputStream class of the java.io package is an abstract superclass representing an output stream of bytes. Since OutputStream is an abstract class, it is not useful by itself. However, its subclasses can be used to write data.


Implemented Interfaces:

Closeable

Flushable

AutoCloseable

Subclasses:

ByteArrayOutputStream

FileOutputStream

FilterOutputStream

ObjectOutputStream

OutputStream

PipedOutputStream

Some methods of OutputStream class

close()This method closes this output stream and releases any system resources associated with this stream. 

flush()This method flushes this output stream and forces any buffered output bytes to be written out.

OutputStream.nullOutputStream()This method returns a new OutputStream which discards all bytes.

write(byte[])This method writes b.length bytes from the specified byte array to this output stream.

write(int)This method writes the specified byte to this output stream

write(byte[], int, int)This method writes len bytes from the specified byte array starting at offset off to this output stream.

No comments:

Post a Comment