public class BrokenOutputStream
extends java.io.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(java.io.IOException exception)
Creates a new stream that always throws the given exception.
|
BrokenOutputStream(java.util.function.Supplier<java.io.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.
|
public static final BrokenOutputStream INSTANCE
public BrokenOutputStream()
IOException
.public BrokenOutputStream(java.io.IOException exception)
exception
- the exception to be thrown.public BrokenOutputStream(java.util.function.Supplier<java.io.IOException> exceptionSupplier)
IOException
.exceptionSupplier
- a supplier for the exception to be thrown.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException
- always thrownpublic void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
- always thrownpublic void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
b
- ignoredjava.io.IOException
- always thrownCopyright © 2010 - 2023 Adobe. All Rights Reserved