public class BrokenOutputStream extends OutputStream
IOException from
all OutputStream methods.
This class is mostly useful for testing error handling in code that uses an output stream.
| Modifier and Type | Field and Description |
|---|---|
static BrokenOutputStream |
INSTANCE
A singleton instance.
|
| Constructor and Description |
|---|
BrokenOutputStream()
Creates a new stream that always throws an
IOException. |
BrokenOutputStream(IOException exception)
Creates a new stream that always throws the given exception.
|
BrokenOutputStream(Supplier<IOException> exceptionSupplier)
Creates a new stream that always throws an
IOException. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Throws the configured exception.
|
void |
flush()
Throws the configured exception.
|
void |
write(int b)
Throws the configured exception.
|
write, writepublic static final BrokenOutputStream INSTANCE
public BrokenOutputStream()
IOException.public BrokenOutputStream(IOException exception)
exception - the exception to be thrown.public BrokenOutputStream(Supplier<IOException> exceptionSupplier)
IOException.exceptionSupplier - a supplier for the exception to be thrown.public void close() throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOException - always thrownpublic void flush() throws IOException
flush in interface Flushableflush in class OutputStreamIOException - always thrownpublic void write(int b) throws IOException
write in class OutputStreamb - ignoredIOException - always thrownCopyright © 2002–2023 The Apache Software Foundation. All rights reserved.