CKTIS / Java
io.IOException: practical reference
io.IOException: practical reference: IOException is the checked base exception for failed or interrupted I/O operations.
Version: Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Syntax
java.io.IOExceptionIOException is the checked base exception for failed or interrupted I/O operations.
Use IOException for checked input/output failures and translate it only at a boundary that can add context or recover.
Catching it does not roll back partial I/O. Preserve the cause and useful subtype when wrapping the failure.
message and cause may be null; try-with-resources can attach close failures as suppressed exceptions.
The example exercises the documented element in a small deterministic program and compares exact standard output.
Examples
public class Main {
public static void main(String[] args) throws Exception {
try { throw new java.io.IOException("disk"); } catch (java.io.IOException error) { System.out.println(error.getMessage()); }
}
}
Result
disk
The example exercises the documented element in a small deterministic program and compares exact standard output.