public class NullOutputStream extends OutputStream
| Constructor and Description |
|---|
NullOutputStream(boolean returnError)
Create a NullOutputStream that will either always throw an IOException
or will always ignore writes.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
This method closes the stream.
|
void |
flush()
This method forces any data that may have been buffered to be written
to the underlying output device.
|
void |
write(byte[] src,
int offset,
int count)
This method writes
len bytes from the specified array
b starting at index off into the array. |
void |
write(int ch)
This method writes a single byte to the output stream.
|
finalize, writepublic NullOutputStream(boolean returnError)
returnError - if this is true any attempted write will throw an IOException,
otherwise it will be ignored.public void write(int ch)
throws IOException
OutputStreamint passed as the argument.
Subclasses must provide an implementation of this method.
write in class OutputStreamch - The byte to be written to the output stream, passed as
the low eight bits of an intIOException - If an error occurspublic void write(byte[] src,
int offset,
int count)
throws IOException
OutputStreamlen bytes from the specified array
b starting at index off into the array.
This method in this class calls the single byte write()
method in a loop until all bytes have been written. Subclasses should
override this method if possible in order to provide a more efficent
implementation.
write in class OutputStreamsrc - The array of bytes to write fromoffset - The index into the array to start writing fromcount - The number of bytes to writeIOException - If an error occurspublic void flush()
throws IOException
OutputStreamThis method in this class does nothing.
flush in class OutputStreamIOException - If an error occurspublic void close()
throws IOException
OutputStreamThis method in this class does nothing.
close in class OutputStreamIOException - If an error occurs