DthingApi
Public Member Functions | List of all members
java.io.OutputStream Class Referenceabstract
Inheritance diagram for java.io.OutputStream:
com.yarlungsoft.util.SystemPrintStream java.io.ByteArrayOutputStream java.io.FileOutputStream java.io.FilterOutputStream java.io.DataOutputStream java.io.PrintStream

Public Member Functions

 OutputStream ()
 
void close () throws IOException
 
void flush () throws IOException
 
void write (byte[] buffer) throws IOException
 
void write (byte[] buffer, int offset, int count) throws IOException
 
abstract void write (int oneByte) throws IOException
 

Detailed Description

A writable sink for bytes.

Most clients will use output streams that write data to the file system (FileOutputStream), the network (java.net.Socket#getOutputStream()/java.net.HttpURLConnection#getOutputStream()), or to an in-memory byte array (ByteArrayOutputStream).

Use OutputStreamWriter to adapt a byte stream like this one into a character stream.

Most clients should wrap their output stream with BufferedOutputStream. Callers that do only bulk writes may omit buffering.

Subclassing OutputStream

Subclasses that decorate another output stream should consider subclassing FilterOutputStream, which delegates all calls to the target output stream.

All output stream subclasses should override both write(int) and write(byte[],int,int). The three argument overload is necessary for bulk access to the data. This is much more efficient than byte-by-byte access.

See also
InputStream

Constructor & Destructor Documentation

◆ OutputStream()

java.io.OutputStream.OutputStream ( )
inline

Default constructor.

Member Function Documentation

◆ close()

void java.io.OutputStream.close ( ) throws IOException
inline

Closes this stream. Implementations of this method should free any resources used by the stream. This implementation does nothing.

Exceptions
IOExceptionif an error occurs while closing this stream.

◆ flush()

void java.io.OutputStream.flush ( ) throws IOException
inline

Flushes this stream. Implementations of this method should ensure that any buffered data is written out. This implementation does nothing.

Exceptions
IOExceptionif an error occurs while flushing this stream.

◆ write() [1/3]

void java.io.OutputStream.write ( byte []  buffer) throws IOException
inline

Equivalent to

write(buffer, 0, buffer.length)

.

◆ write() [2/3]

void java.io.OutputStream.write ( byte []  buffer,
int  offset,
int  count 
) throws IOException
inline

Writes

count

bytes from the byte array

buffer

starting at position

offset

to this stream.

Parameters
bufferthe buffer to be written.
offsetthe start position in
buffer
from where to get bytes.
countthe number of bytes from
buffer
to write to this stream.
Exceptions
IOExceptionif an error occurs while writing to this stream.
IndexOutOfBoundsExceptionif
offset < 0
or
count < 0
, or if
offset + count
is bigger than the length of
buffer
.

◆ write() [3/3]

abstract void java.io.OutputStream.write ( int  oneByte) throws IOException
abstract

Writes a single byte to this stream. Only the least significant byte of the integer

oneByte

is written to the stream.

Parameters
oneBytethe byte to be written.
Exceptions
IOExceptionif an error occurs while writing to this stream.

The documentation for this class was generated from the following file: