public class IORuntimeException extends RuntimeException
IORuntimeException is a runtime exception that is thrown when an operation
involving an underlying IO resource fails or is unable to complete.
This exception is often used to wrap checked exceptions related to IO operations,
such as IOException, into an unchecked exception. This is useful in contexts
where it is inconvenient to handle or propagate the checked exceptions.
The class also provides a utility method to convert general exceptions into IORuntimeException,
specializing the exception as ClosedIORuntimeException if the underlying IO resource is closed.
Example usage:
try {
// Perform some IO operation
} catch (IOException e) {
throw new IORuntimeException("Failed to perform the IO operation", e);
}
| Constructor and Description |
|---|
IORuntimeException(String message)
Constructs an
IORuntimeException with the specified detail message. |
IORuntimeException(String message,
Throwable thrown)
Constructs an
IORuntimeException with the specified detail message and cause. |
IORuntimeException(Throwable thrown)
Constructs an
IORuntimeException with the specified cause. |
| Modifier and Type | Method and Description |
|---|---|
static IORuntimeException |
newIORuntimeException(Exception e)
Creates a new
IORuntimeException based on the provided exception. |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic IORuntimeException(String message)
IORuntimeException with the specified detail message.
The detail message is meant to provide more information on why the exception was thrown.message - The detail message, which is saved for later retrieval by the Throwable.getMessage() method.public IORuntimeException(Throwable thrown)
IORuntimeException with the specified cause.
This constructor is typically used to wrap a lower-level exception.thrown - The cause of the exception, which is saved for later retrieval by the Throwable.getCause() method.public static IORuntimeException newIORuntimeException(Exception e)
IORuntimeException based on the provided exception.
If the exception indicates a closed IO resource, a ClosedIORuntimeException is created.
Otherwise, a regular IORuntimeException is created.e - The exception to create the IORuntimeException from.IORuntimeException, which could be a specialized ClosedIORuntimeException if the underlying resource is closed.Copyright © 2024. All rights reserved.