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, write
public 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
OutputStream
int
passed as the argument.
Subclasses must provide an implementation of this method.
write
in class OutputStream
ch
- The byte to be written to the output stream, passed as
the low eight bits of an int
IOException
- If an error occurspublic void write(byte[] src, int offset, int count) throws IOException
OutputStream
len
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 OutputStream
src
- 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
OutputStream
This method in this class does nothing.
flush
in class OutputStream
IOException
- If an error occurspublic void close() throws IOException
OutputStream
This method in this class does nothing.
close
in class OutputStream
IOException
- If an error occurs